北京到贵州高铁:我做的C++编程题错在哪里?(题目要求是求6个数中最大的数及其位置)

来源:百度文库 编辑:中科新闻网 时间:2024/04/30 03:22:44
#include<iostream.h>
int max(int t[][3],int s,int g);
void main()
{ int a,b,c,d,e,f;
cout<<"请输入6个数组成一个二维数组:\n";
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
cin>>f;
int sg[2][3]={{a,b,c},{d,e,f}};
cout<<"The max is"<<max<<endl;
}
int max(int t[][3],int s,int g)
{ int max=0;
int x=0;
int y=0;
for(int i=0;i<s;i++)
for(int j=0;j<g;j++)
if(t[i][j]>max)
{
max=t[i][j];
x=i+1;
y=j+1;
}
cout<<"最大数的行数为"<<x<<"最大数的列数为"<<y<<endl;
return max;
}

请放到百度知道 > 电脑/数码 > 编程