题解 | #小乐乐与字符串#

小乐乐与字符串

https://www.nowcoder.com/practice/e09de1fc11db4a438cf8f0668848660d

#include <stdio.h>
int main(){
    char str[8001]={0};
    scanf("%s",str);
    char *p=str;
    long long int c=0,ch=0,chn=0;
    while(*p){
        if(*p=='C'){
            c++;
        }else if(*p=='H'){
            ch+=c;
        }else if(*p=='N'){
            chn+=ch;
        }
        p++;
    }
    printf("%lld",chn);
}

全部评论

相关推荐

做个有文化的流氓:不想当将军的士兵不是好士兵
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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