1108 String复读机
作者:互联网
代码
#include <iostream>
#include <cstdio>
#include <string>
#include <map>
using namespace std;
int main()
{
string s;
map<char,int> mp;
mp['S']=0;
mp['t']=0;
mp['r']=0;
mp['i']=0;
mp['n']=0;
mp['g']=0;
cin>>s;
for(int i=0;s[i]!=NULL;i++){
mp[s[i]]++;
}
while(mp['S']!=0||mp['t']!=0||mp['r']!=0||mp['i']!=0||mp['n']!=0||mp['g']!=0){
if(mp['S']!=0){
cout<<'S';
mp['S']--;
}
if(mp['t']!=0){
cout<<'t';
mp['t']--;
}
if(mp['r']!=0){
cout<<'r';
mp['r']--;
}
if(mp['i']!=0){
cout<<'i';
mp['i']--;
}
if(mp['n']!=0){
cout<<'n';
mp['n']--;
}
if(mp['g']!=0){
cout<<'g';
mp['g']--;
}
}
return 0;
}
标签:std,map,String,int,复读机,++,mp,include,1108 来源: https://www.cnblogs.com/wodeblog1982/p/16483104.html