2016-06-27 Problem Solving►UVa UVa 12405 - Scarecrow Contents 1. Problem2. Solution3. Code Problem題目網址中文網址 Solution只要有 . 就讓它右邊放一個稻草人,此時包括自身、左右兩旁皆可保護到。所以 . 下兩格無須判斷。 CodeUVa 12405123456789101112131415161718192021222324252627282930313233#include<cstdio>int main(){ int Case; scanf("%d", &Case); for (int c = 1; c <= Case; c++) { int n, i, count = 0; char ch; scanf("%d", &n); getchar(); for (i = 0; i < n; i++) if (getchar() == '.') { count++; i += 2; if (i < n) { getchar(); getchar(); } } getchar(); printf("Case %d: %d\n", c, count); } return 0;} Newer UVa 341 - Non-Stop Travel Older UVa 12149 - Feynman