for(x=0;x<=(j*3)+2;x++){
for(y=0;y<=(i*3)+2;y++){
should probably be
for(x=3*j;x<=(j*3)+2;x++){
for(y=i*3;y<=(i*3)+2;y++){
to loop over the nine cells of one block.
Note that you can simplify
for(k=0;k<=8;k++){
if(tempsudoku[x][y]==k+1){
check[k]++;
}
}
to
k = tempsudoku[x][y];
if (k >= 1)
check[k-1]++;