프로그래밍/알고리즘
백준2562 최대값
ILove_NS_MoKa
2019. 8. 30. 22:19
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
|
#include <iostream>
int GetMaxNum(int list[], int size);
int main()
{
const int n = 9;
int list[n] = {0,};
int input = 0;
int temp = 0;
int index = 0;
for (int idx = 0; idx < n; idx++)
{
scanf("%d", &input);
list[idx] = input;
}
index = GetMaxNum(list, n);
printf("%d\n%d", list[index], index+1);
return 0;
}
int GetMaxNum(int list[],int size)
{
int temp = 0;
int index = 0;
for (int idx = 0; idx < size; idx++)
{
if (list[idx] > temp)
{
temp = list[idx];
index = idx;
}
}
return index;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |