| ||||||||||
| 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 | |||||||||
晕死用Gcc就能A ,用C就Runtime Error,,帮我看一下是什么原因呢,找了半天找不出来#include <stdio.h>
#define MAXN 10
#define inf 0x7fff
int board[MAXN][MAXN];
int n,k;
int getcnum()
{
int c=0;
int col[MAXN]={0},row[MAXN]={0};
int h=0,w=0,i=0,t=0;
col[0] = -1;
do
{
w = col[h];
w++;
if(w>n||h>=n)
{
col[h--] = -1;
if(col[h]!=n)
{
t--;
row[col[h]] = 0;
}
continue;
}
//找到下一个可放位置或着不放、、col[h] == n 代表不放
while(w!=n&&(board[h][w]==inf||row[w]==1))w++;
//可以放置
col[h++] = w;
col[h] = -1;
if(w!=n){
row[w] = 1;
t++;
}
if(t==k)//成功放置一组
{
c++;
row[col[--h]] = 0;
t--;
}
} while(h!=-1);
return c;
}
int main()
{
int i,j;
char ch;
while (1)
{
scanf("%d%d%*c",&n,&k);
if(n==-1)break;
for(i=0;i<n;i++)
{
for (j=0;j<n;j++)
{
scanf("%c",&ch);
if(ch == '.')board[i][j] = inf;
else board[i][j] = 0;
}
scanf("%*c");
}
printf("%d\n",getcnum());
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator