1043 输出 PATest (20 分)
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cmath>
- using namespace std;
- int main()
- {
- int P=0,A=0,T=0,e=0,s=0,t=0;
- string str;
- cin>>str;
- for(int i=0;i<str.length();i++)
- {
- if(str[i]=='P') P++;
- else if(str[i]=='A') A++;
- else if(str[i]=='T') T++;
- else if(str[i]=='e') e++;
- else if(str[i]=='s') s++;
- else if(str[i]=='t') t++;
- }
- while(1)
- {
- if(P)
- {
- cout<<'P';
- P--;
- }
- if(A)
- {
- cout<<'A';
- A--;
- }
- if(T)
- {
- cout<<'T';
- T--;
- }
- if(e)
- {
- cout<<'e';
- e--;
- }
- if(s)
- {
- cout<<'s';
- s--;
- }
- if(t)
- {
- cout<<'t';
- t--;
- }
- if(P==0&&A==0&&T==0&&e==0&&s==0&&t==0) break;
- }
- return 0;
- }
来源: http://www.bubuko.com/infodetail-3394805.html