題目
http://luckycat.kshs.kh.edu.tw/homework/q12405.htm

注意事項:
1. 稻草人能插在任何地方(良田和不毛之地)
2. 一個稻草人能守住3格的地方

#include <stdio.h>

int main()
{
    int case_n, n, i, j, size, count;
    char str[101];

    fscanf(stdin, "%d", &case_n);
    
    for (i=0; i<case_n; i++)
    {
        fscanf(stdin, "%d", &n); 
        fscanf(stdin, "%s", str);
        
        size = count = 0;
        for (j=0; j<n; j++)
        {
            if (str[j] == '.')
            {
                count++;
                j += 2;
            }
        }
        printf("Case %d: %dn", i+1, count);
    }
    return 0;
}

arrow
arrow
    全站熱搜

    wbkuo 發表在 痞客邦 留言(0) 人氣()