i'm a beginner in c++ i want to programming sudoku i start with a
9x9 table but i had difficulties to continue
1)how to make a function to check numb in the row,colones,and 3x3
2)a counter to know when the game end or repeat until there is no values
#include "suduko.h"
#include <iostream.h>
void main()
{
int i,j ;
int t[9][9] ;
for(i=0;i<9;i++)
for(j=0;j<9;j++)
{
t[i][j]=0;
t[0][0]=5;
t[2][0]=1;
t[4][0]=4;
t[5][0]=2;
t[3][1]=9;
t[5][1]=7;
t[1][2]=9;
t[2][2]=7;
t[8][2]=1;
t[1][3]=4;
t[5][3]=1;
t[6][3]=2;
t[7][3]=3;
t[2][4]=9;
t[6][4]=6;
t[1][5]=5;
t[2][5]=2;
t[3][5]=6;
t[7][5]=1;
t[0][6]=2;
t[6][6]=3;
t[7][6]=9;
t[3][7]=8;
t[5][7]=3;
t[3][8]=4;
t[4][8]=5;
t[6][8]=8;
t[8][8]=2;
}
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
cout<<t[i][j]<<" ";
cout<<endl;
}
}
and this is the function that i tried
bool val (int t [][9])
{
int i,j;
bool comp;
comp= true;
for (int a=0;a<9;a++)
if(a!=j && t[i][a]=t[i][j])
comp false;
for(int b=0;b<9;b++)
if(b!=i && t[b][j]==t[i][j])
comp false;
for( b=(i/3)*3;b<(i/3)*3+3;b++)
for(int col=(j/3)*3;col<(j/3)*3+3;col++)
if(b!=i&&col!=j && t[b][col]==t[i][j])
comp=false;
for( i=0;i<9;i++)
for( j=0;j<9;j++)
if(t[i][j]!=0)
comp=false;
for( i=0;i<9;i++)
for(int j=0;j<9;j++)
if ( t[i][j]<0 || t[i][j]>9 )
comp=false;
return comp;
}