| ||||||||||
| 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;
while(1)
{
cin>>n;
if(n==0) break;
string s;
cin>>s;
int count=0;
int total=0;
char bed[20];
for(int i=0;i<s.length();i++)
{
int nFlag=0;
for(int j=0;j<count;j++)
{
if(bed[j]==s[i])
{
for(int k=j;k<count-1;k++)
{
bed[j]=bed[j+1];
}
nFlag=1;
count--;
break;
}
}
if(nFlag==0 && count<n)
{
bed[count]=s[i];
count++;
}
else if(nFlag==0 && count==n) total++;
}
if(total==0) cout<<"All customers tanned successfully."<<endl;
else cout<<total/2<<" customer(s) walked away."<<endl;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator