1138: 零起点学算法45——求最大值
Description
输入一些整数,求最大值
Input
多组测试数据
首先输入1个整数n表示测试组数
然后每行首先输入1个整数m,再输入m个整数
Output
对于每组测试数据输出1行,内容为m个整数的最大值
" class="reference-link">Sample Input 
2
2 1 2
5 3 4 6 9 3
Sample Output
2
9
Source
零起点学算法
Code
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
int m;
cin>>m;
int t;
int k=-999999;
while(m--)
{
cin>>t;
if(t>=k)
k=t;
}
cout<<k<<endl;
}
}
超级低级的错误
在这个多组不要用while输入啊姐姐
还没有评论,来说两句吧...