题解 | #ZOJ#
ZOJ
https://www.nowcoder.com/practice/7557d470617c464f9200d93acf721471
#include <stdio.h> #include <string.h> int main(){ char text[101]; gets(text); int len = strlen(text); int countZ = 0; int countO = 0; int countJ = 0; for (int i = 0; i < len; ++i) { if (text[i] == 'Z'){ countZ++; } else if (text[i] == 'O'){ countO++; } else if (text[i] == 'J'){ countJ++; } } //输出 while (countZ > 0 || countO > 0 || countJ > 0){ if(countZ > 0){ printf("Z"); countZ--; } if(countO > 0){ printf("O"); countO--; } if(countJ > 0){ printf("J"); countJ--; } } return 0; }