得分问题(算法竞赛入门经典)

#include <stdio.h>
#include "stdafx.h"
#include <iostream>
#include<string.h>
#define maxn 1000
using std::cin;
using std::cout;
int main() {
    char s[maxn];
    scanf_s("%c", s);
    int i = 0, j = 0, k = 0, m = 0;
    int len = strlen(s);
    while (i <= len) {
        if(s[i]=='o'){
            if (s[i] == s[j]) {
                j = i;
                i++;
                k += 1;
                m += k;
            }
            else {
                j = i, i++, k++;
                m += k;
            }
        }
        else if (s[i] == 'x') {
            j = i, i++, k = 0;
            m += k;
        }
    }
    cout << m;
}

猜你喜欢

转载自www.cnblogs.com/NK-007/p/9225641.html