zoj1405
来源:互联网 发布:怎么优化宝贝标题贴吧 编辑:程序博客网 时间:2024/06/05 02:48
简单题
#include <iostream>#include <string>using namespace std;int main(){ int num; while(1) { cin >> num; if(!num) break; string people,nobeds; cin >> people; string beds; int times = 0; for(string::iterator it = people.begin();it != people.end();it++) { if(beds.find(*it) != string::npos) { for(string::iterator it2 = beds.begin();it2 != beds.end();it2++) if(*it2 == *it) { beds.erase(it2); break; } } else if(beds.size() == num) { if(nobeds.find(*it) != string::npos) times ++; else nobeds += *it; } else if(beds.size() < num) beds += *it; } if(times) cout << times << " customer(s) walked away." <<endl; else cout << "All customers tanned successfully." << endl; } return 0;}
0 0