//1、建立二維數組 //2、運用循環,將內容輸入到數組中 //3、求出最大元素,並輸出行號和列號 #include<iostream> using namespace std; int main() { int a[3][4]; int Max=0;//賦值之前需要先置為0 cout<<"please input 12 numbers: "<<endl; for(int i=0;i<3;i++)//嵌套循環,用於向二維數組中輸入內容 { for(int j=0;j<4;j++) { cin>>a[i][j]; } } for(int m=0;m<3;m++)//用於判斷數組中的最大元素是多少 { for(int n=0;n<4;n++) { if(a[m][n]>=Max) { Max=a[m][n]; } } } cout<<"the biggest number is "<<Max<<endl; for(int p=0;p<3;p++)//用於判斷最大元素所在的位置 { for(int q=0;q<4;q++) { if(Max==a[p][q]) { cout<<"它在第"<<p+1<<"行,"<<"第"<<q+1<<"列"<<endl; } } } return 0; }