爬格子呀4-2

中途去了一趟北京,好几天没写代码了,今天瞎写了一段

没跑代码

#include<stdio.h>
int main() {
    int m, n, a[9][9][2], i, j, count=0, x, y, k;
    char c[2];
    scanf_s("%d%d", m, n);
    for (i = 0; i < m; i++) {
        scanf_s("%s%d%d", c,&x,&y);
        if (c[0] == 'H') a[x-1][y-1][0] = 1;
        else a[x - 1][y - 1][1] = 1;
    }
    for (i = 0; i < n-1; i++) {
        for (j = 0; j < n-1; j++) {
            for (k = 0; k < (n - i < n - j ? n - i : n - j); k++) {
                if (a[i][j+k][0] == 1 && a[i+k][j][1] == 1) {
                    if (a[i + k][j][0] == 1 && a[i][j + k][1]) count++;
                }
                else break;
            }
        }
    }
    printf("%d", count);
    return 0;
}
posted @ 2017-08-15 13:49  romaLzhih  阅读(79)  评论(0编辑  收藏  举报