fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. //必要があれば変数などを追加してもOKです
  5.  
  6. int main(){
  7. int i,j,k;
  8. int a,b;
  9. int **mat;
  10. scanf("%d %d",&a,&b);
  11.  
  12. mat=malloc(a*sizeof(int*));
  13. for(i=0;i<a;i++)
  14. {mat[i]=malloc(b*sizeof(int));}
  15.  
  16. for(i=0;i<a;i++)
  17. {for(j=0;j<b;j++)
  18. {printf("%d ",mat[i][j]);}
  19. printf("\n");}
  20.  
  21. free(mat);
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5276KB
stdin
3 3
stdout
0 0 0 
0 0 0 
0 0 0