#include <cstdio>
using namespace std;
#define FOR(x,y,z) for(int (x)=(y);(x)<(z);++(x))
const int maxn = 10 + 10;
char m[maxn][maxn];
int main(){
int t,cntcase = 0,n;
scanf("%d",&t);
while(t--){
scanf("%d",&n);getchar();
FOR(i,0,n) gets(m[i]);
FOR(i,0,n){
FOR(j,0,n){
if(m[i][j] == ‘.‘){
for(char ch = ‘A‘;ch <= ‘Z‘;++ch){
if(i > 0 && m[i - 1][j] == ch) continue;
if(i < n-1 && m[i + 1][j] == ch) continue;
if(j > 0 && m[i][j - 1] == ch) continue;
if(j < n - 1 && m[i][j + 1] == ch) continue;
m[i][j] = ch;break;
}
}
}
}
printf("Case %d:\n",++cntcase);
FOR(i,0,n) puts(m[i]);
}
return 0;
}
[2016-03-19][UVA][11520][Fill the Square]
原文:http://www.cnblogs.com/qhy285571052/p/d8c9f50c0f47dc45b2d1139fdfbb10b4.html