I am trying to read a soduku file. Can somebody help me how to create a main rou
ID: 3629502 • Letter: I
Question
I am trying to read a soduku file. Can somebody help me how to create a main routine with atleast a one subroutine to validate a set of nine values?Validating for each of the 9 columns, for each of the 9 rows as well as for each of the 9 3x3 block to see if they contain same numbers (excluding a zero, since it is reserve for a blank square.)
The subroutine must return a validity indicator either with a traditional return or as a value in the structure and it must accept as input either an array of nine values or a pointer to a structure containing to an array of nine values.
Any help will be appreciated.
Explanation / Answer
please rate - thanks
hope this will get you started
#include <conio.h>
#include <stdio.h>
int checkValues(int[],int[]);
int main()
{int numbersNeed[9]={1,2,3,4,5,6,7,8,9};
int numbersHave[9]={1,2,3,4,5,6,7,8,9};
int numbersHave2[9]={1,1,2,3,4,5,6,7,8};
if(checkValues(numbersNeed,numbersHave)==1)
printf("1st comparison they are good ");
else
printf("1st comparison they are bad ");
if(checkValues(numbersNeed,numbersHave2)==1)
printf("2nd comparison they are good ");
else
printf("2nd comparison they are bad ");
getch();
return 0;
}
int checkValues(int need[],int have[])
{int used[9],i,j;
for(i=0;i<9;i++)
used[i]=0;
for(i=0;i<9;i++)
for(j=0;j<9;j++)
if(have[i]==need[j])
{used[j]=1;
j=10;
}
for(i=0;i<9;i++)
if(used[i]==0)
return 0;
return 1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.