数独解答判定プログラム
数独の解答判定プログラムを作成しているのですが、完成しません。下に僕の作ったプログラムを載せておくので間違い等の指摘をお願いします。
#include <stdio.h>
#define row 9
#define column 9
int question[row][column]={
915284376,
273916584,
468753912,
396178245,
742365891,
851492637,
629847153,
587631429,
134529768,
};
int num;
int singlenumber(void);
int saferow(int, int);
int safecolumn(int, int);
int safebox(int, int, int);
int main(void){
int judge;
for(num = 1; num <= 9; num++){
int singlenumber(void);
}
if(judge == 0){
printf("おめでとう!! 正解です。");
}else{
printf("残念!! 不正解です。");
}
return 0;
}
int singlenumber(void){
int i, j;
int row_judge;
int column_judge;
int box_judge;
int judge;
for(i = 0; i < row; i++){
int saferow(int i, int num);
}
for(j = 0; j < column; j++){
int safecolumn(int j, int num);
}
for(i = 0; i < row; i++){
for(j = 0; j < column; j++){
int safebox(int i, int j, int num);
}
}
if(row_judge == 0 && column_judge == 0 && box_judge == 0){
judge = 0;
}else{
judge = 1;
}
return judge;
}
int saferow(int i, int num){
int k;
int row_judge;
for(k = 0; k < column; k++){
if(num == question[i][k]){
row_judge = 0;
}else{
row_judge = 1;
}
}
return row_judge;
}
int safecolumn(int j, int num){
int l;
int column_judge;
for(l = 0; l < row; l++){
if(num == question[l][j]){
column_judge = 0;
}else{
column_judge = 1;
}
}
return column_judge;
}
int safebox(int i, int j, int num){
int m, n;
int box_judge01, box_judge02, box_judge03;
int box_judge11, box_judge12, box_judge13;
int box_judge21, box_judge22, box_judge23;
int box_judge0, box_judge1, box_judge2, box_judge;
for(m = 0; m < row ; m++){
if(m / 3 == 0){
for(n = 0; n < 3; n++){
if(num == question[m][n]){
box_judge01 = 0;
}else{
box_judge01 = 1;
}
}
for(n = 3; n < 6; n++){
if(num == question[m][n]){
box_judge02 = 0;
}else{
box_judge02 = 1;
}
}
for(n = 6; n < 9; n++){
if(num == question[m][n]){
box_judge03 = 0;
}else{
box_judge03 = 1;
}
}
}
if(box_judge01 == 0 && box_judge02 == 0 && box_judge03 == 0){
box_judge0 = 0;
}else{
box_judge0 = 1;
}
if(m / 3 == 1){
for(n = 0; n < 3; n++){
if(num == question[m][n]){
box_judge11 = 0;
}else{
box_judge11 = 1;
}
}
for(n = 3; n < 6; n++){
if(num == question[m][n]){
box_judge12 = 0;
}else{
box_judge12 = 1;
}
}
for(n = 6; n < 9; n++){
if(num == question[m][n]){
box_judge13 = 0;
}else{
box_judge13 = 1;
}
}
}
if(box_judge11 == 0 && box_judge12 == 0 && box_judge13 == 0){
box_judge1 = 0;
}else{
box_judge1 = 1;
}
if(m / 3 == 2){
for(n = 0; n < 3; n++){
if(num == question[m][n]){
box_judge21 = 0;
}else{
box_judge21 = 1;
}
}
for(n = 3; n < 6; n++){
if(num == question[m][n]){
box_judge22 = 0;
}else{
box_judge22 = 1;
}
}
for(n = 6; n < 9; n++){
if(num == question[m][n]){
box_judge23 = 0;
}else{
box_judge23 = 1;
}
}
}
if(box_judge21 == 0 && box_judge22 == 0 && box_judge23 == 0){
box_judge2 = 0;
}else{
box_judge2 = 1;
}
if(box_judge0 == 0 && box_judge1 == 0 && box_judge2 == 0){
box_judge = 0;
}else{
box_judge = 1;
}
}
return box_judge;
}