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> #define MAX 50 using namespace std; typedef struct salon{ int sign; char ch; }salon; salon s[MAX]; int z; int num; int yesorno(salon s[],int k) { for(int i=0;i<k;i++) if(s[i].ch==s[k].ch) { z=i; if(s[i].sign==1) return 1; else if(s[i].sign>=2) return 2; } return 0; } int getth(salon s[],int n) { int k=0; for(int i=0;i<n&&k<num;i++) if(s[i].sign==1) k++; return k; } void main() { while(cin>>num&&num!=0) { char bed[MAX]; string ss; cin>>ss; int ans=0; for(int i=0;i<ss.size();i++) { s[i].ch=ss[i]; if(yesorno(s,i)==1) { s[z].sign=0; for(int k=0;k<i;k++) if(s[k].sign>=2) { s[k].sign=1; break; } } else if(yesorno(s,i)>=2) { s[z].sign=0; ans++; } else { if(getth(s,i)<num) s[i].sign=1; else s[i].sign=2; } // for(int j=0;j<=i;j++) // cout<<s[j].ch; // cout<<endl; // for(j=0;j<=i;j++) // cout<<s[j].sign; // cout<<endl; } if(ans==0) cout<<"All customers tanned successfully."<<endl; else cout<<ans<<" customer(s) walked away."<<endl; } } 把//去掉的话,会打印出每输入一个字母沙龙里座位情况,1表示有人正在用,2表示在等待,0表示已经走了 哪不对啊 小弟笨死了,看不出来 哪位大哥帮忙看看啦 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator