哈工大机考:求最大值

时间限制:1秒 空间限制:32768K

题目描述

输入10个整数,要求输出其中的最大值。
输入描述:
测试数据有多组,每组10个整数。


输出描述:
对于每组输入,请输出其最大值(有回车)。

输入例子:
10 22 23 152 65 79 85 96 32 1

输出例子:
max=152
上代码:
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int a[10];
  while(cin>>a[0]){
  for(int i=1;i<10;i++)
     cin>>a[i];
  sort(a,a+10);
  cout<<"max="<<a[9]<<endl;
  }
}
原文地址:https://www.cnblogs.com/mlgjb/p/6908716.html