-
Title Description:
-
read into a string, the string contains zoj three characters, the number is not necessarily equal, in the order of zoj output, when a character runs out, the rest is still in the order of zoj output.
-
Input:
-
The topic contains multiple sets of use cases, one for each group of use cases, containing zoj three characters, and the end of the input when the "E" is entered.
1<=length<=100.
-
Output:
-
For each set of inputs, output a line that represents the string after processing as required.
A concrete example of the visible sample.
-
Sample input:
-
Zzooojjjzzzzooooojjjzooojje
-
Sample output:
-
Zojzojojzojzojzojzoozojojo
#include <iostream>#include<cstring>using namespacestd;intMain () {strings; while(Getline (cin,s) && s!="E"){ intz=0, o=0, j=0; for(intI=0; I<s.size (); i++){ if(s[i]=='Z') z++; Else if(s[i]=='O') o++; Else if(s[i]=='J') J + +; } for(;z>0&& o>0&& j>0; z--, o--, j--) {cout<<"ZOJ"; } if(z==0){ for(;o>0&& j>0; O--, j--) {cout<<"OJ"; } if(o==0) { for(;j>0; j--) cout<<"J"; } Else for(;o>0; o--) cout<<"O"; } if(o==0){ for(;z>0&& j>0; Z--, j--) {cout<<"ZJ"; } if(z==0) { for(;j>0; j--) cout<<"J"; } Else for(;z>0; z--) cout<<"Z"; } if(j==0){ for(;o>0&& z>0; O--, z--) {cout<<"ZO"; } if(o==0) { for(;z>0; z--) cout<<"Z"; } Else for(;o>0; o--) cout<<"O"; } cout<<Endl; } return 0;}
1032.ZOJ problem