UVA11520 Fill the Square 枚举

    xiaoxiao2023-03-16  5

    这些题目都不叫水,博主都懒得说了,直接贴代码吧,博主刚刚AC了,虽然很容易,博主也只是练一下手。(谁叫博主马上要写替罪羊树了,替罪羊树的网址————————-) 博主不多说了,直接上代码:

    /************************************************************************* > File Name: \LJF\UVa\UVa_11520.cpp > Author: ljf_cnyali > Mail: 2724424647@qq.com > Last modifiedz: 2016-09-19 19:33 > Description: This is a large group of God's program information. ************************************************************************/ #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<ctime> #include<algorithm> #include<queue> #include<set> #include<ctime> using namespace std; #define REP(i, a, b) for(int i = (a), _end_ = (b);i <= _end_; ++i) const int maxn = 20; char map[maxn][maxn]; int main() { int n, m; scanf("%d", &m); int t = m; while(m--) { scanf("%d", &n); REP(i, 1, n) { getchar(); REP(j, 1, n) scanf("%c", &map[i][j]); } REP(i, 1, n) REP(j, 1, n) if(map[i][j] == '.') REP(c, 'A', 'Z') { if(i < n && c == map[i + 1][j]) continue; if(i > 1 && c == map[i - 1][j]) continue; if(j < n && c == map[i][j + 1]) continue; if(j > 1 && c == map[i][j - 1]) continue; map[i][j] = c; break; } printf("Case %d:\n", t - m); REP(i, 1, n) { REP(j, 1, n) printf("%c", map[i][j]); puts(""); }; } return 0; }
    转载请注明原文地址: https://ju.6miu.com/read-1152723.html
    最新回复(0)