Created
January 24, 2013 11:22
-
-
Save ahfoukou/4620264 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void create_puzzle(char board[][9]) | |
{ | |
char buffer[50] = { 0 }; | |
int i=0, k=0; | |
clrscr(); | |
gotoxy(0,21); | |
clear_puzzle(board); | |
printf("\nManually create a sudoku puzzle!\n "); | |
while (i < 9) | |
{ | |
print_puzzle(board, NULL); | |
gotoxy(0,23); | |
printf("Insert the line number %d\n",i+1); | |
scanf("%s", buffer); | |
// ekxwrei grammi grammi opws zitate to sudoku kai ka8e fora elegxei ama to sudoku einai egguro me ta noumera pou dinei | |
if(strlen(buffer) != 9) | |
{ | |
printf("The number of numbers for each line must be 9\n"); | |
system("pause"); | |
} | |
//h sunartisi sscanf se sundiasmo me to %1d pairnei apo to string buffer 1 stoixeio ka8e fora kai to ekxwrei ston pinaka , auto to kanw epeidi 8elete na ekxwroume grammi grammi ka8e fora alla exw ton pinaka char | |
else | |
{ | |
sscanf(buffer, "%1d%1d%1d%1d%1d%1d%1d%1d%1d", &board[i][0], &board[i][1], &board[i][2], &board[i][3], &board[i][4], &board[i][5], &board[i][6], &board[i][7], &board[i][8]); | |
printf("\n\n"); | |
if (valid_puzzle(board)) | |
i++; | |
else | |
printf("The puzzle is not valid, please enter line number %d again.\n",i+1); | |
} | |
clrscr(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment