提交时间:2019-12-14 14:28:45
运行 ID: 3198
#include "stdio.h" #include <stdlib.h> int main(int argv,char *argc[]){ int n,**a,*b,i,j; printf("Input n(int 2<n<8)...\nn="); if(scanf("%d",&n)!=1 || n<3 || n>7){ printf("Input error, exit...\n"); return 0; } b=(int *)malloc(sizeof(int)*n*n); if(!b || (a=(int **)malloc(sizeof(int*)*n))==NULL){ printf("Application memory failure...\n"); return 0; } for(j=i=0;i<n;a[i++]=b+j,j+=n); for(i=0;i<n;i++){ for(j=0;j<n;printf("%3d",a[i][j++]=i*j)); printf("\n"); } free(b); free(a); return 0; }