您的位置:首页 > 其它

poj1250 Tanning Salon

2013-10-19 10:30 260 查看
#include<stdio.h>
#include<string.h>

void main(){
int n;
char s[53],c[26];
int i,l,count,leave;
scanf("%d",&n);
while(n != 0 && n<=20){
memset(s,'\0',sizeof(s));
memset(c,'0',sizeof(c));
scanf("%s",s);
l=strlen(s);
count=0;
leave=0;
for(i=0;i<l;i++){
if(count >= n){
if(c[s[i]-65] == '0'){
c[s[i]-65]='2';
leave++;
continue;
}
else if(c[s[i]-65]=='2'){
continue;
}
}
if(c[s[i]-65] == '0'){
c[s[i]-65] = '1';
count++;
}
else if(c[s[i]-65] == '1'){
c[s[i]-65] = '0';
count--;
}
}
if(leave == 0)
printf("All customers tanned successfully.\n");
else
printf("%d customer(s) walked away.\n",leave);
scanf("%d",&n);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: