Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C Compiler.
  4. Code, Compile, Run and Debug C program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13. int d = 0;
  14. int ***p = (int ***) malloc(sizeof(int**) * 3);
  15.  
  16. for(int i = 0; i < 3; i++) {
  17. *(p + i) = (int **) malloc(sizeof(int*) * 3);
  18.  
  19. for(int j = 0; j < 3; j++) {
  20. *(*(p + i) + j) = (int*) malloc(sizeof(int) * 3);
  21.  
  22. for(int k = 0; k < 3; k++) {
  23. *(*(*(p + i) + j) + k) = d++;
  24. }
  25. }
  26. }
  27.  
  28. for(int i = 0; i < 3; i++) {
  29. for(int j = 0; j < 3; j++) {
  30. for(int k = 0; k < 3; k++) {
  31. printf("%d\t", *(*(*(p + i) + j) + k));
  32. }
  33. printf(" | ");
  34. }
  35. printf("\n");
  36. }
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement