题目链接:点击打开链接
知识点笔记:
AC代码:
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
char dic[6]={'P','A','T','e','s','t'};
int count[6]={0};
int num=0;
char str[10000];
gets(str);
int len = strlen(str);
for(int i=0;i<len;i++){
char c =str[i];
if(c=='P'){
count[0]++;
num++;
}else if(c=='A'){
count[1]++;
num++;
}else if(c=='T'){
count[2]++;
num++;
}else if(c=='e'){
count[3]++;
num++;
}else if(c=='s'){
count[4]++;
num++;
}else if(c=='t'){
count[5]++;
num++;
}
}
for(int i=0;num>0;i++){
if(i==6)
i=0;
if(count[i]>0){
printf("%c",dic[i]);
count[i]--;
num--;
}
}
return 0;
}