杭電ACM-2071 Max Num
阿新 • • 發佈:2018-11-16
Max Num
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29053 Accepted Submission(s): 16466
Problem Description There are some students in a class, Can you help teacher find the highest student .
Input There are some cases. The first line contains an integer t, indicate the cases; Each case have an integer n ( 1 ≤ n ≤ 100 ) , followed n students’ height.
Output For each case output the highest height, the height to two decimal plases;
Sample Input
Sample Output 180.00 182.00
沒什麼好說的,計算最大值,兩位小數輸出。
AC程式碼如下:
#include<iostream> #include<iomanip> using namespace std; int main() { int n,m; double num,max; cin>>n; for(int i=0;i<n;i++) { max=0.00; //初始化最好放在外迴圈裡。 cin>>m; for(int j=0;j<m;j++) { cin>>num; if(num>max) //比較最大值,置換 { max=num; } else continue; } cout<<fixed<< setprecision(2)<<max<<endl; //兩位輸出 } return 0; }