Thread: 3 dimentional arrays

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    808

    3 dimentional arrays

    how can i do this
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
        int test[3][3][9] = { 0 };
    
        for ( int i = 0; i < 3; i++ )
            for ( int j = 0; j < 3; j++ )
                for ( int z = 0; z < 9; z++ )
                    test[i][j][z] = z + 1;
    
        int counter = 1;
        for ( int i = 0; i < 3; i++ )
            for ( int j = 0; j < 3; j++ )
            {
                test[i][j] = counter;
                counter++;
            }
    
        for ( int i = 0; i < 3; i++ )
            for ( int j = 0; j < 3; j++ )
            {
                for ( int z = 0; z < 9; z++ )
                    printf("i = %d j = %d z = %d element = %d\n", i, j, z, test[i][j][z]);
            putchar('\n');
            }
    
        return 0;
    }
    i need to make a suduko grid im trying to put the solved squares in co-ordinates i and j and the possible values in z
    Last edited by cooper1200; 06-15-2023 at 07:27 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with multi-dimentional arrays in C
    By thebenman in forum C Programming
    Replies: 3
    Last Post: 11-01-2014, 09:13 AM
  2. 2 dimentional array
    By gameover6005 in forum C Programming
    Replies: 2
    Last Post: 04-16-2013, 09:07 PM
  3. Accessing column data in multi-dimentional arrays
    By Darkmentor in forum C Programming
    Replies: 5
    Last Post: 11-30-2012, 11:51 AM
  4. 3 Dimentional string Arrays
    By paulroseby in forum C Programming
    Replies: 3
    Last Post: 11-27-2002, 06:53 AM
  5. moving n-dimentional arrays in c++
    By kknla in forum C++ Programming
    Replies: 0
    Last Post: 02-06-2002, 05:15 PM

Tags for this Thread