C++语言如何找出一列数中最大的数

来源:百度知道 编辑:UC知道 时间:2024/05/25 20:51:10

这个。。。别把它想复杂了就好

#include <iostream>
using namespace std;
int input(){
int a[10];
int i,b;
for (i=0;i<10;i++){
cout<<"Input the value of number "<<i+1;
cin>>a[i];
}
b=a[0];
for (i=1;i<10;i++){
if (b<a[i]){
b=a[i];
}
}
return b;
}

int main(){
cout<<"The Biggest number: "<<input()<<endl;
return 0;
}

int a[10]={1,1,1,1,1,1,1,1,2,3};
int i,j,k;
j=a[0];
for(i=1;i<10;i++)
{
if(j<a[i])j=a[i];

}
j就是最大的。