fork download
  1. #include<stdio.h>
  2.  
  3. void changematrix(int **mm,int row, int column){
  4. int i,j;
  5. for( i = 0;i < row; i++){
  6. for( j = 0; j < column; j++){
  7. *(*(mm + i) + j) = 2* *(*(mm + i) + j);
  8. //mm[i][j] *= 2;
  9. }
  10. }
  11. }
  12.  
  13. int main(void){
  14. int i,j;
  15. int row, column;
  16. printf("Type the number of row\n");
  17. scanf("%d", &row);
  18. printf("Type the number of columns\n");
  19. scanf("%d", &column);
  20. int mat[row][column];
  21. int *mm[row];
  22.  
  23. for(i = 0; i < row; ++i)
  24. mm[i] = mat[i];
  25.  
  26. printf("Now type the numbers\n");
  27. for( i = 0; i < row; i++){
  28. for( j = 0; j < column; j++){
  29. scanf("%d", &mat[i][j]);
  30. }
  31. }
  32.  
  33. changematrix(mm, row, column);
  34.  
  35. for( i = 0; i < row; i++){
  36. for( j = 0; j < column; j++){
  37. printf("%d ", mat[i][j]);
  38. }
  39. printf("\n");
  40. }
  41. }
Success #stdin #stdout 0s 9432KB
stdin
3
3
1 2 3
4 5 6
7 8 9
stdout
Type the number of row
Type the number of columns
Now type the numbers
2 4 6 
8 10 12 
14 16 18