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

哪位大牛帮忙看看哪错了

Posted by 3080434005 at 2009-03-15 21:47:52 on Problem 2225
#include<iostream>
using namespace std;
int dir[][2] = {{1, 0},{0, 1},{-1, 0},{0, -1}};
int n;
char map[100][12];
struct Node
{
  int C, R;
  int M;
  int step;
}queue[10000000], end;
bool ok(int x, int y)
{
	if(x < 0 || x >= n * n || y < 0 || y >= n)
		 return false;
	return map[x][y] == 'O';
}
int main()
{
	char t[8], e[8];
	while(1 == scanf("%s", t) )
	{
		scanf("%d", &n);
		int i;
		for(i = 0; i < n * n; i ++)
			scanf("%s", &map[i]);
        scanf("%d %d %d", &queue[0].C, &queue[0].R, &queue[0].M );
		queue[0].R += queue[0].M * n;
        queue[0].step = 0;
		scanf("%d %d %d", &end.C, &end.R, &end.M );
		end.R += end.M * n;
		scanf("%s", e);
		int k = 0;
		int t = 1;
		bool res = false;
	 while( t != k)
	 {
		if(queue[k].R == end.R && queue[k].C == end.C)
		{
			res = true;
			break;
		}
        for(i = 0; i < 4; i ++)
		{
           if(ok(queue[k].R + dir[i][0], queue[k].C + dir[i][1]))
		   {
                queue[t].step = queue[k].step + 1;
			    queue[t].R = queue[k].R + dir[i][0];
				queue[t].C =  queue[k].C + dir[i][1];
				map[queue[t].R][queue[t].C] = 'X';
				t ++;
		   }
		}
		k ++;
	 }
	 if(res)
		 printf("%d %d\n", n, queue[k].step);
	 else
		 printf("NO ROUTE\n");
	}
	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