50169. Sum of Integers

難度:3.9/5

看好題目再下手。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>
#include "sumOfIntegers.h"

void sumOfIntegers(const int *ptr_arr[], int ans[], int *num){
int cnt = 0;
int now_head = 0;
while(1){
if(ptr_arr[now_head] == NULL) break;

int i, this_sum = 0;
for(i = now_head; ptr_arr[i] != NULL; i++){

int appeared = 0;
for(int j = now_head; j < i; j++){
if(ptr_arr[i] == ptr_arr[j]){
appeared = 1;
break;
}
}
if(!appeared) this_sum += *ptr_arr[i];
}
ans[cnt++] = this_sum;
now_head = (i + 1);
}
*num = cnt;
}


50169. Sum of Integers
https://aaronlin1229.github.io/judgegirl_50169/
Author
Akizumi
Posted on
July 17, 2023
Licensed under