| ||||||||||
| 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 | |||||||||
帮帮忙看下#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator