Need help with a Sudoku verifying program
What I can see that we are dealing with is that I need to use multidimensional arrays.
I'm suppose to verify an input file with sudoku solutions, "sudoku-solution.c" is correct or not.
The input file is the following:
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9 1 2 3 4 5 6 7 8
So far what I have is
Code:
#include <stdio.h>
FILE *fp;
int main()
{
int i, sudoku[9][9];
fp = fopen("sudoku-solution.txt","r");
for(i=1;i<10;i++)
{
fscanf(fp,"%d", &sudoku[9][i]);
}
for(i=1;i<10;i++)
printf("%d", sudoku[2][i]);
}
I did this to test what my values I'm scanning are. I'm just getting the first row, any tips on how I should go about doing this? I'm think that I should verify that each row vertically and horizontally add up to 45. Is there a way to print values vertically? Also is there a way to the values in the next row?
Thanks