题目:
题解:
#include<iostream>
#include<map>
using namespace std;
map<char, int>mp;
int main()
{
string key = "String";
string t;
cin >> t;
//记录字符数量
for (int i = 0; i < t.size(); i++)
{
mp[t[i]]++;
}
//输出
//全部输出完才能结束输出
while (mp['S'] != 0 || mp['t'] != 0 || mp['r'] != 0 || mp['i'] != 0 || mp['n'] != 0 || mp['g'] != 0)
{
for (int i = 0; i < key.size(); i++)
{
if (mp[key[i]] > 0)
{
mp[key[i]]--;
cout << key[i];
}
}
}
return 0;
}
标签:PAT,String,int,复读机,++,mp,key,size
From: https://blog.csdn.net/2301_79580018/article/details/139542445