ZOJ

发布时间:2025-12-09 11:48:00 浏览次数:1

题目描述 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当某个字符用完时,剩下的仍然按照ZOJ的顺序输出。 输入描述: 题目包含多组用例,每组用例占一行,包含ZOJ三个字符,当输入“E”时表示输入结束。 1<=length<=100。 输出描述: 对于每组输入,请输出一行,表示按照要求处理后的字符串。 具体可见样例。 示例1 输入

ZZOOOJJJ ZZZZOOOOOJJJ ZOOOJJ E 输出

ZOJZOJOJ ZOJZOJZOJZOO ZOJOJO


#include <iostream>#include <map>#include <string>using namespace std;string str;map<char,int> Map;int main(){    while(cin>>str){        if(str == "E"){            break;        }        Map.clear();        for(int i = 0 ; i < str.length() ; i++){            Map[str[i]]++;        }        int numz = Map['Z'];        int numo = Map['O'];        int numj = Map['J'];        while(numz || numo || numj){            if(numz){                cout<<"Z";                numz--;            }            if(numo){                cout<<"O";                numo--;            }            if(numj){                cout<<"J";                numj--;            }        }        cout<<endl;    }    return 0; } 
zoj
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477