题解 | #ZOJ#
ZOJ
https://www.nowcoder.com/practice/7557d470617c464f9200d93acf721471
#include<cstdio> #include<string> using namespace std; int main() { char arr[101]; scanf("%s", arr); string str = arr; int len = str.size(); int count0; int count1; int count2; for (int i = 0 ; i < len ; ++i) { if (str[i] == 'Z') { ++count0; } if (str[i] == 'O') { ++count1; } if (str[i] == 'J') { ++count2; } } while (count1 != 0 || count0 != 0 || count2 != 0 ) { if(count0 != 0){ printf("%c", 'Z'); --count0; } if(count1 != 0){ printf("%c", 'O'); --count1; } if(count2 != 0){ printf("%c", 'J'); --count2; } } }