版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/polanwind/article/details/88086487
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int n;
int ans;
char temp[1005][1005];
int main() {
scanf("%d", &n);
for (int i = 1;i <= n;++i) {
for (int j = 1;j <= n;++j) {
if (i % 2 == 1) {
if (j % 2 == 1) {
temp[i][j] = 'C';
ans++;
}
else {
temp[i][j] = '.';
}
}
else {
if (j % 2 == 1) {
temp[i][j] = '.';
}
else {
temp[i][j] = 'C';
ans++;
}
}
}
}
printf("%d\n", ans);
for (int i = 1;i <= n;++i) {
for (int j = 1;j <= n;++j) {
printf("%c", temp[i][j]);
}
printf("\n");
}
return 0;
}