题解 | #ZOJ#
ZOJ
https://www.nowcoder.com/practice/7557d470617c464f9200d93acf721471
#include <iostream> using namespace std; int main() { string str; cin >> str; int z = 0,o = 0,j = 0; for(int i = 0;i < str.size();i++) { if(str[i] == 'Z') z++; if(str[i] == 'O') o++; if(str[i] == 'J') j++; } while(z != 0 || o != 0 || j != 0) { if(z > 0) { cout <<'Z'; z--; } if(o > 0){ cout << 'O' ; o--; } if(j > 0){ cout << 'J'; j--; } } return 0; }