您的位置:首页 > 其它

[sicily]1157. The hardest problem

2015-09-24 21:15 357 查看

1157. The hardest problem

Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

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.

Sample Input


1 1

2 1 2

3 1 3 2

4 1 2 3 4

0

Sample Output


1

2

3

4

简单求最大值问题,注意有负数存在

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
int n;
while(cin>>n && n!=0)
{
int tmp, max=-65535;
for(int i=0; i<n; i++)
{
cin>>tmp;
if(tmp > max)
max = tmp;
}
cout<<max<<endl;

}

// system("pause");
return 0;
}

Submit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sicily