fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void){
  5. int a,b,n=1;
  6. printf("Please enter in the order of row, column");
  7. scanf("%d%d", &a, &b);
  8. int *p = (int*)malloc(sizeof(int)* a * b);
  9. for(int i=0; i < a; i++){
  10. for(int j=0; j < b; j++){
  11. *(p + i + b * j) = n;
  12. printf("%d ", n);
  13. n++;
  14. }
  15. printf("\n");
  16. }
  17. free(p);
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5272KB
stdin
3 4
stdout
Please enter in the order of row, column1 2 3 4 
5 6 7 8 
9 10 11 12