-
Notifications
You must be signed in to change notification settings - Fork 0
/
SUMMER_Lab02_3.c
53 lines (46 loc) · 1.03 KB
/
SUMMER_Lab02_3.c
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//백준 2309
#include <stdio.h>
int total_sum = 0;
int total[9];
void find_ans() {
for (int j = 0; j < 9; j++) {
int temp_sum = total[j];
for (int k = j + 1; k < 9; k++) {
temp_sum += total[k];
if (total_sum - temp_sum == 100) {
total[j] = 0;
total[k] = 0;
return;
}
temp_sum = total[j];
}
}
}
void sort_array() {
int i, j, temp;
for (i = 0; i < 9 - 1; i++) {
for (j = 0; j < 9 - i - 1; j++) {
if (total[j] > total[j + 1]) {
temp = total[j];
total[j] = total[j + 1];
total[j + 1] = temp;
}
}
}
}
int main() {
for (int i = 0; i < 9; i++) {
int num;
scanf("%d", &num);
total[i] = num;
total_sum += total[i];
}
find_ans();
sort_array();
for (int j = 0; j < 9; j++) {
if (total[j] != 0) {
printf("%d\n", total[j]);
}
}
return 0;
}