| ||||||||||
| 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<stdlib.h>
#include<stdio.h>
#include<math.h>
using namespace std;
bool ff1=false,ff2=false;
char a[100],b[100];
int c[100];
int main(){
int m,len,dex,ans,dd,cc;
while(cin>>m&&m){
memset(b,' ',sizeof(b));
memset(c,0,sizeof(c));
ans=0;
cc=0;
cin>>a;
len=strlen(a);
for(int i=0;i<len;i++){
ff1=false;ff2=false;
for(int k=0;k<m;k++){
if(a[i]!=b[k]){
continue;
}else{
ff2=true;
dd=k;
break;
}
}
if(!ff2){
for(int j=0;j<m;j++){
if(b[j]==' '){
b[j]=a[i];
ff1=true;
break;
}else {
continue;
}
}
if(ff1)continue;
if(!ff1&&c[a[i]-'A']==0){
c[a[i]-'A']=1;
ans++;continue;
}else
continue;
}else{
b[dd]=' ';
continue;
}
}
if(ans==0)cout<<"All customers tanned successfully."<<endl;
else
cout<<ans<<" 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