关于二维数组的问题
程序代码:
程序如下: 建立一个二维数组,存储星期一到星期五每天早、中、晚三个时段的温度。 然后输出星期一到星期五每天的平均温度。 但是我每次都得不出正确答案。 到底是哪里出错了,请大家指正一下!!! #include <iostream> #include <string> using std::cout; using std::cin; using std::string; using std::endl; int main(){ int a,b,sum=0; float aver=0; float air_humidity[4][2]; for(a=0;a<5;a++) { switch(a){ case 0:cout<<"enter the monday is: "; break; case 1:cout<<"enter the Tuesday is: ";break; case 2:cout<<"enter the wednesday is: ";break; case 3:cout<<"enter the thursday is: ";break; case 4:cout<<"enter the friday is: ";break; } for(b=0;b<3;b++) {if(b==0) cout<<"please enter morning: "; else if(b==1) cout<<"please enter afternoon: "; else cout<<"please enter night: "; cin>>air_humidity[a][b]; } } for(a=0;a<5;a++) { switch(a){ case 0:cout<<"the monday is: "; break; case 1:cout<<"the Tuesday is: ";break; case 2:cout<<"the wednesday is: ";break; case 3:cout<<"the thursday is: ";break; case 4:cout<<"the friday is: ";break; } for(b=0;b<3;b++) { sum=sum+air_humidity[a][b];} aver=sum/3; cout<<aver<<endl; sum=0; } system("pause"); }