算法入门经典P57-习题3-1(简单模拟)

2021/11/3 17:12:14

本文主要是介绍算法入门经典P57-习题3-1(简单模拟),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

#include<iostream>
#include<string.h>
using namespace std;
int main(){
    char s[85];
    scanf("%s",s);
    int i,j=0,score=0,len = strlen(s); 
    for(i=0;i<len;i++){
        if(s[i]=='O'){
            j++;
            score += j;
        }
        else{
            j = 0;
        }
    }
    printf("%d\n",score);
    return 0;
}

 



这篇关于算法入门经典P57-习题3-1(简单模拟)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程