-
Notifications
You must be signed in to change notification settings - Fork 0
/
일곱 난쟁이.cpp
66 lines (59 loc) · 953 Bytes
/
일곱 난쟁이.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
using namespace std;
void calculate(int i, int j, int height[], int newHeight[])
{
int sum = 0;
for (int n = 0; n < 9; n++)
{
if (n == i || n == j)
continue;
sum += height[n];
}
if (sum == 100)
{
int m = 0;
for (int n = 0; n < 9; n++)
{
if (n != i && n != j)
{
newHeight[m] = height[n];
m++;
}
}
}
}
void accending(int newHeight[])
{
for (int i = 0; i < 6; i++)
{
int min = newHeight[i];
for (int j = i + 1; j < 7; j++)
{
if (min > newHeight[j])
{
min = newHeight[j];
newHeight[j] = newHeight[i];
newHeight[i] = min;
}
}
}
}
int main(void)
{
int height[9];
int newHeight[7];
for (int i = 0; i < 9; i++)
cin >> height[i];
for (int i = 0; i < 9; i++)
{
int n = 0;
for (int j = i + 1; j < 9; j++)
{
calculate(i, j, height, newHeight);
}
}
accending(newHeight);
cout << "\n";
for (int i = 0; i < 7; i++)
cout << newHeight[i] << "\n";
}