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 bushiniao at 2006-10-30 19:30:46 on Problem 1250
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	char *s=new char[10000];
	while(cin>>n&&n)
	{
		cin>>s;
		int i=0;
		int length=strlen(s);
		bool status[30]={false};
		int arrival=0;
		int left=0;
		i=0;
		while(s[i]!='\0')
		{
			if(arrival<n&&status[s[i]-'A']==false)
			{
				arrival++;
				status[s[i]-'A']=true; 
				i++;
			} //表示人数未满且该人刚来
			else if(arrival<n&&status[s[i]-'A']==true)
			{
				arrival--;
				status[s[i]-'A']=false;
				i++;
			}//表示人数未满且该人已经来了,
			else if(arrival>=n&&status[s[i]-'A']==true)
			{
				arrival--;
				status[s[i]-'A']=false;
				i++;
			}//人书已满,这个人来个了,现在是回去
			else if(arrival>=n&&status[s[i]-'A']==false)
			{
				left++;
				status[s[i]-'A']=true;
				i++;
			}//人已满,这个人到来

		}
		if(left==0)
			cout<<"All customers tanned successfully."<<endl;
		else
			cout<<left<<" customer(s) walked away."<<endl;
	}

}

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