#include <iostream>
#include <stdlib.h>
using namespace std;
void func()
{
int n;
int i=0;
int max;
while(cin>>n)
{
i++;
if(i==1)max=n;
else{
if(max<n)max=n;
if(i==10){cout<<"max="<<max<<endl;
i=0;}
}
}
}
int main(int argc, char *argv[])
{
//printf("Hello, world\n");
func();
return 0;
}
顺序求最大值,也可以用堆
-
题目描述:
-
输入10个数,要求输出其中的最大值。
-
输入:
-
测试数据有多组,每组10个数。
-
输出:
-
对于每组输入,请输出其最大值(有回车)。
-
样例输入:
-
10 22 23 152 65 79 85 96 32 1
-
样例输出:
-
max=152