当前位置: 代码迷 >> C语言 >> 麻烦各位看看有关数组的问题
  详细解决方案

麻烦各位看看有关数组的问题

热度:94   发布时间:2005-04-03 16:53:00.0
麻烦各位看看有关数组的问题

#include<stdio.h> main(){ /*此段代码是为测试中途对未经初始化的一维及二维数组进行赋值后数组中的各数值情况*/ int *pl,(*ph)[4],aa[3][4],a[3][4]={{1,2, 3, 4}, {5,6, 7, 8}, {9,10,11,12}}; int i,j,m,n; int b[3][4],c[3][4],d[5];

printf("\n****the test 1:****\n"); pl=a; /*行地址赋列指针变量*/ ph=&a[0][1]; /*列地址赋行指针变量*/ printf("%d,%d\n",*pl,*(*ph+1));

printf("only input one value to the group when run(result):\n"); scanf("%d",aa[0]); /*0行行地址*/ for(i=0;i<3;i++) for(j=0;j<4;j++) { printf("%d ",aa[i][j]); if(j==3)printf("\n"); }

printf("\n****the test 2:****\n"); printf("input only head of every line:\n"); for(i=0;i<3;i++) scanf("%d",b[i]); /*输入表列只写二维数组的行首地址*/ printf("\noutput:\n"); for(i=0;i<3;i++) for(j=0;j<4;j++) { printf("%d ",b[i][j]); if(j==3)printf("\n"); }

printf("\n****the test 3:****\n"); printf("2 digits group:\n"); scanf("%d",c[0]); for(m=0;m<3;m++) for(n=0;n<4;n++) { printf("%d ",c[m][n]); if(n==3)printf("\n"); }

printf("\n\n1 digits group:\n"); scanf("%d",d); /*输入表列只写一维数组的数组名即以此种方式输入第一个数*/ for(n=0;n<5;n++) printf("%d ",d[n]);

getch(); }

搜索更多相关的解决方案: 麻烦  

----------------解决方案--------------------------------------------------------
  相关解决方案