2013
12-10

# Sudoku Killer

7 1 2 ? 6 ? 3 5 8
? 6 5 2 ? 7 1 ? 4
? ? 8 5 1 3 6 7 2
9 2 4 ? 5 6 ? 3 7
5 ? 6 ? ? ? 2 4 1
1 ? 3 7 2 ? 9 ? 5
? ? 1 9 7 5 4 8 6
6 ? 7 8 3 ? 5 1 9
8 5 9 ? 4 ? ? 2 3

7 1 2 4 6 9 3 5 8
3 6 5 2 8 7 1 9 4
4 9 8 5 1 3 6 7 2
9 2 4 1 5 6 8 3 7
5 7 6 3 9 8 2 4 1
1 8 3 7 2 4 9 6 5
2 3 1 9 7 5 4 8 6
6 4 7 8 3 2 5 1 9
8 5 9 6 4 1 7 2 3

#include<stdio.h>
#include<string.h>
int map[9][9],num;
struct node
{
int x,y;
}s[81];
bool judge(int t,int cur)
{
int i,j;
for(i = 0 ; i < 9 ; i ++)
if(map[ s[cur].x ][i] == t || map[i][ s[cur].y ] == t)//同行或同列数字是否重复
return 0;
int x = s[cur].x/3 * 3;
int y = s[cur].y/3 * 3;
for(i = 0 ; i < 3 ; i ++)//同一3*3方格里的数字是否重复
for(j = 0 ; j < 3 ; j ++)
if(map[x + i][y + j] == t) return 0;
return 1;

}
void dfs(int cur)
{
int i,j,flag = 0;
if(cur == num)
{
for(i = 0 ; i < 9 ; i ++)
{
for(j = 0 ; j < 9 ; j ++)
{
if(j == 8)
{
printf("%d\n",map[i][j]);
break;
}
printf("%d ",map[i][j]);
}
}
flag = 1;
return ;
}
for(i = 1 ; i <= 9 ; i ++)
{
if(judge(i,cur) && !flag)
{
map[ s[cur].x ][ s[cur].y ] = i;
dfs(cur + 1);
map[ s[cur].x ][ s[cur].y ] = 0;
}
}
}
int main()
{
//freopen("in.txt","r",stdin);
int i = 0 , j = 0 ,p = 0;
num = 0 ;
char a[2];
while(~scanf("%s",a))
{
if(a[0] != '?') map[i][j] = a[0] - '0';
else
{
map[i][j] = 0;
s[num].x = i;
s[num].y = j;
num ++;
}
j ++;
if(j == 9)   { i ++;  j = 0; }
if(i == 9)
{
if(p) printf("\n");
p ++;
dfs(0);
i = j = num = 0;
}
}
return 0;
}

1. Gucci New Fall Arrivals

This is really nice to know. I hope it will be successful in the future. Good job on this and keep up the good work.

2. #include <cstdio>

int main() {