| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
郁闷 为什么用char 数组就OLE 只能用int 数组吗?贴下代码,求为什么?#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define M 11
struct point { int x, y; } p[100];
char map[M][M];
bool row[M][M], col[M][M], mat[3][3][M];
int np;
void DFS(int num)
{
int i, j;
if (num == np) {
for (i = 0; i < 9; i++) {
for (j = 0; j < 9; j++)
printf ("%c", map[i][j]);
printf ("\n");
}
return;
}
for (i = 1; i <= 9; i++) {
int x = p[num].x;
int y = p[num].y;
if (!row[x][i] && !col[y][i] && !mat[x/3][y/3][i]) {
row[x][i] = col[y][i] = mat[x/3][y/3][i] = true;
map[x][y] = '0' + i;
DFS(num+1);
row[x][i] = col[y][i] = mat[x/3][y/3][i] = false;
map[x][y] = '0';
}
}
}
int main()
{
int t, i, j;
scanf ("%d", &t);
getchar();
while (t--) {
memset (row, false, sizeof (row));
memset (col, false, sizeof (col));
memset (mat, false, sizeof (mat));
np = 0;
for (i = 0; i < 9; i++) {
gets(map[i]);
for (j = 0; j < 9; j++) {
int num = map[i][j] - '0';
if (num)
row[i][num] = col[j][num] = mat[i/3][j/3][num] = true;
else {
p[np].x = i;
p[np++].y = j;
}
}
}
DFS(0);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator