Created
April 14, 2021 12:53
-
-
Save mingkyme/790c54e3e0d6c6f62f6c920b001d76ff 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
int main() | |
{ | |
int array[4][4] = { | |
{4,3,0,0}, | |
{1,2,3,0}, | |
{0,0,2,0}, | |
{2,1,0,0} | |
}; | |
int i, j, k; | |
for ( i = 0; i < 4; i++) { | |
for ( j = 0; j < 4; j++) { | |
if (array[i][j] == 0) { | |
int canAnswers[4] = { 1, 2, 3, 4 }; | |
for ( k = 0; k < 4; k++) { | |
if (array[k][j] != 0) { | |
canAnswers[array[k][j] - 1] = 0; | |
} | |
if (array[i][k] != 0) { | |
canAnswers[array[i][k] - 1] = 0; | |
} | |
} | |
int answer = -1; | |
for ( k = 0; k < 4; k++) { | |
if (canAnswers[k] != 0) { | |
answer = canAnswers[k]; | |
break; | |
} | |
} | |
array[i][j] = answer; | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment