给一维数组输入7个整数,找出该数组中的最大数。
程序运行结果如下:
输入:
234 12 34 56 34 23 89
输出:
234
送分题+1
#include<iostream>
using namespace std;
int main(){
int n,x,max;
cin>>max;
for (int i=2;i<=7;i++){
cin>>x;
if (x>max) max=x;
}
cout<<max;
return 0;
}
给一维数组输入7个整数,找出该数组中的最大数。
程序运行结果如下:
输入:
234 12 34 56 34 23 89
输出:
234
送分题+1
#include<iostream>
using namespace std;
int main(){
int n,x,max;
cin>>max;
for (int i=2;i<=7;i++){
cin>>x;
if (x>max) max=x;
}
cout<<max;
return 0;
}