๋ฌธ์
ํ์ด
#include <bits/stdc++.h>
using namespace std;
int main() {
// ์
๋ ฅ๋ ๋์์ด๋ค์ ํค
int array[9];
for (int i = 0; i < 9; i++) {
cin >> array[i];
}
// ๋์์ด ์ ๋ ฌ (์ค๋ฆ์ฐจ์)
for (int n = 0; n < 9; n++) {
for (int m = n + 1; m < 9; m++) {
if (array[m] <= array[n]) {
int tmp = array[n];
array[n] = array[m];
array[m] = tmp;
}
}
}
// ๋์์ด๋ค์ ํค ํฉ
int totalLength = 0;
for (int i: array) {
totalLength += i;
}
// ์ ์ธํ ๋์์ด๋ค
int exclude[2];
// ์ฐพ๊ธฐ
for (int n = 0; n < 9; n++) {
for (int m = n + 1; m < 9; m++) {
int result = totalLength - array[n] - array[m];
if (result == 100) {
exclude[0] = n;
exclude[1] = m;
break;
}
}
}
cout << "\n";
// ์ธ๋ฑ์ค
int index = 0;
// ๊ฒฐ๊ณผ
int result[7];
for (int i = 0; i < 9; i++) {
if (i != exclude[0] && i != exclude[1]) {
result[index] = array[i];
index++;
}
}
for (int i: result) {
cout << i << "\n";
}
return 0;
}
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 2979] ํธ๋ญ ์ฃผ์ฐจ (0) | 2023.03.28 |
---|---|
[๋ฐฑ์ค 10808] ์ํ๋ฒณ ๊ฐ์ (0) | 2023.03.28 |
ํ๋ก๊ทธ๋๋จธ์ค | 3์ง๋ฒ ๋ค์ง๊ธฐ (0) | 2020.12.17 |
ํ๋ก๊ทธ๋๋จธ์ค | ์ฒด์ก๋ณต, ๊ทธ๋ฆฌ๋ ์๊ณ ๋ฆฌ์ฆ (2) | 2020.12.12 |
ํ๋ก๊ทธ๋๋จธ์ค | ํฌ๋ ์ธ ์ธํ๋ฝ๊ธฐ ๊ฒ์, Stack (0) | 2020.12.11 |