-
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
-
Source:
-
2009 Zhejiang University computer and software engineering research on the real problem of life test
-
Answering:
-
problem solving problems? to discuss the subject of discussion please visit: http://t.jobdu.com/thread-7756-1-1.html
#include <stdio.h> #include <string.h> int main () {char s[100]; int i; while (scanf ("%s", s)!=eof) {if (strcmp (S, "E") ==0) break; int z=0,o=0,j=0; for (i=0;s[i]!= '; i++) {if (s[i]== ' Z ') z++; else if (s[i]== ' O ') o++; else J + +; } if (Z>o) {if (o>j) {//Z o J for (i=0;i<j;i++) printf ("ZOJ"); for (i=0;i<o-j;i++) printf ("ZO"); for (i=0;i<z-o;i++) printf ("Z"); } else if (z>j) {//Z J O for (i=0;i<o;i++) printf ("ZOJ"); for (i=0;i<j-o;i++) printf ("ZJ"); for (i=0;i<z-j;i++) printf ("Z"); } else{//J Z o for (i=0;i<o;i++) printf ("ZOJ"); for (i=0;i<z-o;i++) printf ("ZJ"); for (i=0;i<j-z;i++) printf ("J"); }}else {if (z>j) {//O Z J for (i=0;i<j;i++) printf ("ZOJ"); for (i=0;i<z-j;i++) printf ("ZO"); for (i=0;i<o-z;i++) printf ("O"); } else if (J>o) {//J O Z for (i=0;i<z;i++) printf ("ZOJ"); for (i=0;i<o-z;i++) printf ("OJ"); for (i=0;i<j-o;i++) printf ("J"); } else {//O J Z for (i=0;i<z;i++) printf ("ZOJ"); for (i=0;i<j-z;i++) printf ("OJ"); for (i=0;i<o-j;i++) printf ("O"); }} printf ("\ n"); } return 0; }/************************************************************** problem:1032 User:vhreal Langu Age:c result:accepted time:0 Ms memory:912 KB ****************************************************************/
Nine degrees oj-topic 1032:zoj