category/백준 알고리즘 c++
백준 알고리즘 2562번 최대 c++
자운대고라니
2020. 12. 13. 23:04
반응형
요약 : 9개의 자연수를 입력 후 최댓값 과 최댓값의 순서 출력
소스코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int array[9] = {0,},num=0;
int max=-100000001;
for(int i=0;i<9;i++) {
cin >> array[i];
if(max<array[i]) {
max=array[i];
num=i+1;
}
}
cout << max << "\n" << num << endl;
return 0;
}
|
cs |
정답 확인
반응형