Description
In the final exam, you are given n problems to solve, each one of which has an integer value indicating its difficulty, the larger, the harder. You need to find out which problem is the hardest.
Input
Input may contain several test cases, one per line. For each test case, the first integer indicates n (1<=n<=4), the number of problems. And then n signed 32-bit integers follow. A case with n=0 indicates the end of input, which should not be processed.
Output
For each test case, you must output the difficulty value of the hardest problem in a single line.
//1157. The hardest problem
#include <iostream>
#include <cstdio>
using namespace std ;
int main (){
long long test = 0 , hard_level = 0 ;
while (cin >> test && test != 0){
long long hardest ;
cin >> hardest ;
for (int i = 0 ; i < test - 1; ++i)
{
cin >> hard_level ;
if(hardest - hard_level < 0 ){
hardest = hard_level ;
}
}
cout << hardest << endl ;
}
return 0 ;
}
本文介绍了一个简单的算法,用于从一组给定的问题中找出难度最大的问题。输入包括一系列测试案例,每个案例首先给出问题的数量,随后列出每个问题的具体难度值。
311

被折叠的 条评论
为什么被折叠?



