紫书思路实现:
#include <iostream>
using namespace std;
char country(int i)
{
return i >= 26? 'a'+i-26: 'A'+i; //不同字母代表不同国家,大写不够小写来凑
}
int main()
{
int n;
while(cin >> n)
{
cout << "2 " << n << " " << n << '\n'; //只有两层,n行n列
// i为行,j为列
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
cout << country(i); //第一层按行输出
cout << '\n';
}
cout << '\n'; //两层之间要换行
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
cout << country(j); //第二层按列输出
cout << '\n';
}
}
return 0;
}