【UVA – 1585】Score【紫书】

【UVA – 1585】Score【紫书】

问题链接:https://vjudge.net/problem/UVA-1585

Solution:

#include <iostream>

using namespace std;

const int LIM = 81;
char data[LIM];

inline char myGetChar() {
    char ret;
    while ((ret = getchar()) != 'X' && ret != 'O' && ret != '\n');
    return ret;
}

int main(void) {
    int t, sum, tmp;
    char ch;
    scanf("%d", &t);
    myGetChar();
    while (t--) {
        tmp = sum = 0;
        while ((ch = myGetChar()) != '\n') {
            if (ch == 'X') tmp = 0;
            else sum += ++tmp;
        }
        printf("%d\n", sum);
    }
    return 0;
}

 

相关阅读:

《算法竞赛入门经典》(紫书)全AC代码