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

谁帮我看看啊!!!为啥WA?????????

Posted by jianxiawzx at 2010-08-11 12:50:01 on Problem 1573
#include<stdio.h>
int main()
{
	int i,j,n,m,began,row,line,step=0;
	char a[20];
	int shuju[10][10];
	while(1)
	{
		scanf("%d %d %d",&n,&m,&began);
			if(n==0&&m==0&&began==0)
				break;
		step=0;
		getchar();
		for(i=0;i<n;i++)
		{
		    
		    gets(a);
		    for(j=0;j<m;j++)
			{
				if(a[j]=='N')
				   shuju[i][j]=-1;
				else if(a[j]=='E')
				   shuju[i][j]=-2;
				else if(a[j]=='S')
				   shuju[i][j]=-3;
				else if(a[j]=='W')
				   shuju[i][j]=-4;
			}
		}
		row=0;line=began-1;
		while(!(row<0||row>=n||line<0||line>=m||shuju[row][line]>0))
		{
			if(shuju[row][line]==-1)
			{
				shuju[row][line]=++step;
				row--;
			}
			if(shuju[row][line]==-2)
			{
				shuju[row][line]=++step;
				line++;
			}
			if(shuju[row][line]==-3)
			{
				shuju[row][line]=++step;
				row++;
			}
			if(shuju[row][line]==-4)
			{
				shuju[row][line]=++step;
			    line--;
			}
		}
		if(shuju[row][line]>0)
			printf("%d step(s) before a loop of %d step(s)\n",shuju[row][line]-1,step-shuju[row][line]+1);
		else printf("%d step(s) to exit\n",step);
	}
	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