poj1250 Tanning Salon

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     char c,p[26];
 6     int n,curnum,leave;
 7     while(scanf("%d%*c",&n),n)
 8     {
 9         curnum=leave=0;
10         memset(p,0,sizeof(p));
11         for(c=getchar();c!='\n';c=getchar()){
12             if(p[c-'A']==1){
13                 p[c-'A']=0;
14                 curnum--;
15             }
16             else if(p[c-'A']==0){
17                 if(curnum<n){
18                     p[c-'A']=1;
19                     curnum++;
20                 }
21                 else{
22                     leave++;
23                     p[c-'A']=2;
24                 }
25             }
26         }
27         if(leave) printf("%d customer(s) walked away.\n",leave);
28         else printf("All customers tanned successfully.\n");
29     }
30     return 0;
31 }
原文地址:https://www.cnblogs.com/shihuajie/p/2626400.html