用C语言编写如下两个关于数组的程序。如何解答?
发布网友
发布时间:2023-10-11 10:59
我来回答
共1个回答
热心网友
时间:2024-11-26 07:00
1)
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
float a[3][4]={{1.1,2.2,3.3,4.4},{5.5,6.6,7.7,8.8},{9.9,10.1,11.11,12.12}};
int i,j;
for(i=0;i<3;i++){
for(j=0;j<4;printf("%10f",a[i][j++]));
printf("\n");
}
return 0;
}
2)
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
float a[2][3][4]={{{0.1,0.2,0.3,0.4},{0.5,0.6,0.7,0.8},{0.9,0.01,0.11,0.12}},
{{1.1,2.2,3.3,4.4},{5.5,6.6,7.7,8.8},{9.9,10.1,11.11,12.12}}};
int i,j,k;
for(i=0;i<2;i++){
for(j=0;j<3;j++){
for(k=0;k<4;printf("%10f",a[i][j][k++]));
printf("\n");
}
printf("\n\n");
}
return 0;
}