fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int i,n,m,**a;
  5. scanf("%d %d",&n,&m);
  6. a=(int**)malloc(sizeof(int*)*n);
  7. for(i=0;i<n;i++){
  8. a[i]=(int*)malloc(sizeof(int));
  9. }
  10. for(i=0;i<n;i++){
  11. for(int j=0;j<m;j++){
  12. a[i][j]=i*m+j;
  13. printf("%3d",a[i][j]);
  14. }
  15. printf("\n");
  16. }
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 5284KB
stdin
5 6
stdout
  0  1  2  3  4  5
  6  7  8  9 10 11
 12 13 14 15 16 17
 18 19 20 21 22 23
 24 25 26 27 28 29