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了几次,将数组开得大了点就AC了

Posted by hacker_2040 at 2013-10-07 11:57:52 on Problem 1250
将visit[26] char str[52]改为visit[30] char str[60]就AC了

#include "stdio.h"
#include "string.h"

int main()
{
	int beds,tan,walk_away,visit[30];
	int i,len,id;
	char str[60];
	while(scanf("%d",&beds)&&beds)
	{
		scanf("%s",str);

		memset(visit,0,sizeof(visit));
		tan=0; walk_away=0;
		len=strlen(str);
		for(i=0;i<len;i++)
		{
			id=str[i]-'A';
			if(visit[id]==0)
			{
				if(tan<beds)
				{
					visit[id]=1;
					tan++;
				}
				else
				{
					visit[id]=2;
					walk_away++;
				}
			}
			else if(visit[id]==1)
				tan--;
			else if(visit[id]==2)
				continue;
		}
		if(!walk_away)
			printf("All customers tanned successfully.\n");
		else
			printf("%d customer(s) walked away.\n",walk_away);
	}
	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