题目内容
运行下面的C程序,并分析运行结果。(1)分析运行结果一#includeint main(){char letter[5]={'a','b','c','d','e'};int i;for(i=0;i<5;i++)printf("%c",letter[i]);return 0;}(2)分析运行结果二#includeint main(){static int n[][4]={{1,2},{3,4,5},{6,7,8,9}};int i,j;for(i=0;i<3;i++)for(j=0;j<4;j++)printf("%d",n[i][j]);return 0;}(3)分析运行结果三#includeint main(){static int n[10]={1,0,0,0,0,0,0,0,0,0};int i,j;for(i=0;i<10;i++)for(j=i;j<10;j++)n[i]=n[i]+n[j];for(i=0;i<10;i++)printf("%d",n[i]);return 0;}(4)分析运行结果四#includeint main(){int matrix[5][5];int i,j;for(i=0;i<5;i++){matrix[i][i]=1;for(j=0;j<5;j++)if(i!=j)matrix[i][j]= matrix[4-j][4-i]+ matrix[j][j];}for(i=0;i<5;i++){for(j=0;j<5;j++)printf("%5d ",matrix[i][j]);printf("\n");}return 0;}(5)分析运行结果五#includeint m[3][3]={{1},{2},{3}};int n[3][3]={1,2,3};int main(){printf("%d\n",m[1][0]+n[0][0]); /*1.结果*/printf("%d\n",m[0][1]+n[1][0]); /*2.结果*/return 0;}(6)分析运行结果六#includeint main(){char str[3][10]={"This","is","test!"};printf("str[2]=%s,str[2][1]=%c,str=%s\n",str[2],str[1][1],str);return 0;}
查看答案
搜索结果不匹配?点我反馈