题目描述
输入10个整数,要求输出其中的最大值。
输入描述:
测试数据有多组,每组10个整数。
输出描述:
对于每组输入,请输出其最大值(有回车)。
示例1
输入
复制
10 22 23 152 65 79 85 96 32 1
输出
复制
max=152
经验分享
可以用标题上的三个函数写出三种不同解法
AC代码
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(){
int n = 10;
int a[20];
for(int i = 0;i < 10;i++){
cin >> a[i];
}
for(int i = 0;i < 10;i++){
n = max(a[i],n);
}
cout << "max=" << n << endl;
return 0;
}