Description
請撰寫一個程式,讓使用者能夠找到不定數量的正整數中的最大值。
Please write a program that allows the user to find the maximum value among an indefinite number of positive integers.
Input
輸入包含一個整數�(20<=�<=100)n(20<=n<=100), 而下一行將有n個正整數。
The input contains an integer �(20<=�<=100)n(20<=n<=100), and the next line will have n positive integers.
Output
請輸出這�n個正整數中最大的那個。
Please output the largest of these n positive integers.
Sample Input 1
5
10 12 13 14 15
Sample Output 1
15
Sample Input 2
8
1 5 3 6 7 8 4 2
Sample Output 2
8
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int n;
int b=-1;
scanf("%d",&n);
int a[n-1];
for(int i = 0; i<n; i++){
scanf("%d",&a[i]);
}
for(int i = n-1; i>=0; i--){
if(b<=a[i]){
b=a[i];
}
}
printf("%d",b);
return 0;
}