Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

郁闷 为什么用char 数组就OLE 只能用int 数组吗?贴下代码,求为什么?

Posted by hejunfei at 2012-03-01 23:08:52 on Problem 2676
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator