Thread: newbe needs some help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2005
    Location
    Alpine, TX
    Posts
    31

    newbe needs some help sodoku puzzle

    Hello all. I am taking my first class in C and have a professor thats all about having you learn on your own. Anyway Im trying to write a solution to the Sodoku puzzle. What I dont know is how to scan a row for a number that I am trying to enter. professor says I should use an index. I have no clue how to set that up. Here is the part that Where I set up the initial puzzle

    Code:
    void getGivens(struct sudoCell grid[9][9]) /* User enters starting pattern */
    {
         int row, col, digit;
         char instring[50];
         printf("Enter Sudoku pattern line by line.\n");
         printf("Enter \'0\' for each undetermined cell\n");
         printf("Enter a digit 1..9 followed by a space for each starting cell\n");
         for (row=0; row<9; ++row)
         {
             /* Users dont understand rows numbered 0 */
             printf("Enter row %d: ", row+1);
             fgets(instring, sizeof(instring), stdin);
             sscanf(instring, "%d %d %d %d %d %d %d %d %d",
                  &grid[row][0].digit, &grid[row][1].digit,
                  &grid[row][2].digit, &grid[row][3].digit,
                  &grid[row][4].digit, &grid[row][5].digit,
                  &grid[row][6].digit, &grid[row][7].digit,
                  &grid[row][8].digit);
             for (col=0; col<9; ++col) 
                  grid[row][col].given = grid[row][col].digit>0;
         }
         return;
    }
    Last edited by Dr Spud; 11-23-2005 at 08:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbe question
    By RaisinToe in forum Game Programming
    Replies: 15
    Last Post: 01-28-2009, 06:01 PM
  2. Newbe request
    By Rokemet in forum C++ Programming
    Replies: 14
    Last Post: 09-20-2007, 11:41 PM
  3. Please help (newbe post)
    By Dmax in forum C++ Programming
    Replies: 4
    Last Post: 02-17-2005, 09:52 PM
  4. Newbe help
    By Kitu in forum C++ Programming
    Replies: 7
    Last Post: 08-01-2004, 03:49 AM
  5. WNDCLASSEX vs. WNDCLASS (Newbe) ???
    By niklaskr in forum Windows Programming
    Replies: 3
    Last Post: 06-19-2002, 09:44 AM