题解 | #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;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-27 20:15
还能挽救吗?找同学帮忙看了一下&nbsp;字节怎么能如此对我
牛客26396789...:你这是严重红线,被发现你自己永远进不去,你那个同学直接走人,你还敢宣扬
点赞 评论 收藏
分享
每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
牛客83700679...:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
评论
4
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务