home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap07 / box.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-05  |  776 b   |  34 lines

  1. /* box.c  --  demonstrate the result of initializing  */
  2. /*            a three-dimensional array               */
  3.  
  4. main()
  5. {
  6.     static int cube[3][3][3] = {
  7.         1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  8.         13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
  9.         23, 24, 25, 26, 27 };
  10.     int plane;
  11.     extern void Draw_plane();
  12.  
  13.     for (plane = 0; plane < 3; ++plane)
  14.         {
  15.         Draw_plane(cube, plane);
  16.         }
  17. }
  18.  
  19. void Draw_plane(int box[3][3][3], int slice)
  20.     {
  21.     int row, col;
  22.  
  23.     printf("Plane[%d] =\n", slice);
  24.     for (row = 0; row < 3; ++row)
  25.         {
  26.         for (col = 0; col < 3; ++col)
  27.             {
  28.             printf( "%2d ", box[slice][row][col]);
  29.             }
  30.         printf("\n");
  31.         }
  32.     printf("\n");
  33. }
  34.