fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5.  
  6. void foo(size_t M, size_t N, int arr[][N])
  7. {
  8. for (size_t m=0;m<M;++m)
  9. {
  10. for (size_t n=0;n<N;++n)
  11. printf("%.3d ", arr[m][n]);
  12. printf("\n");
  13. }
  14. }
  15.  
  16. int main()
  17. {
  18. static const size_t L=5, M=7, N=10;
  19.  
  20. int arr3D[L][M][N];
  21. int *p = arr3D[0][0];
  22. size_t i=0;
  23.  
  24. srand((unsigned)time(0));
  25.  
  26. for (i=0;i<L*M*N;++i)
  27. *p++ = rand() % 1000;
  28.  
  29. for (i=0;i<L;++i)
  30. {
  31. foo(M,N,arr3D[i]);
  32. printf("\n");
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 1788KB
stdin
Standard input is empty
stdout
592 697 761 768 471 570 314 540 830 063 
876 151 013 043 321 593 609 301 030 704 
314 717 401 483 819 191 448 707 157 031 
127 102 081 889 870 904 811 184 444 994 
600 320 145 965 715 466 558 324 119 588 
381 433 658 134 269 477 325 717 536 835 
101 664 937 182 905 159 086 716 343 883 

710 295 555 207 260 623 673 819 947 145 
759 680 930 769 815 199 247 140 269 135 
327 722 799 616 256 704 775 342 773 471 
577 835 766 485 043 379 108 716 198 407 
213 309 088 144 079 903 343 678 395 964 
813 723 686 965 339 942 021 467 637 794 
938 214 630 056 051 673 435 159 741 985 

567 955 295 655 099 726 558 794 404 305 
759 217 380 445 534 072 740 556 539 377 
350 829 943 980 885 995 005 321 154 099 
658 073 054 953 728 505 679 638 651 435 
944 410 005 324 208 539 396 948 095 287 
677 446 116 620 778 002 615 136 675 122 
235 333 195 641 639 276 498 670 914 149 

106 210 560 111 535 120 650 283 420 098 
571 097 544 687 717 674 041 685 162 068 
807 397 754 354 390 393 630 888 415 545 
038 521 755 950 984 642 422 635 278 842 
085 849 939 629 888 008 655 282 693 818 
350 852 567 104 207 310 849 189 550 265 
734 588 138 842 890 123 836 664 110 114 

506 195 315 797 176 204 806 183 486 499 
353 188 704 273 645 263 583 494 452 133 
111 539 074 602 733 316 077 569 981 539 
684 839 734 351 637 262 555 795 797 393 
646 151 582 350 776 579 613 711 073 066 
844 537 957 270 491 690 939 568 259 272 
107 295 111 193 647 100 807 554 247 604