1043 输出PATest (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805280074743808
#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; }
原文地址:https://www.cnblogs.com/jianqiao123/p/12233987.html
时间: 2024-10-30 15:05:18