【例题 8-2 UVA-1605】Building for UN

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

两层 然后n*n就够了 第一层类似 aaa.. bbb.. ccc.. ... 第二次则变成 abc.... abc.... abc.... .... 这样就能保证每个字母都和其他的字母有相邻的了。(不同层的相同位置

【代码】

/*
  	1.Shoud it use long long ?
  	2.Have you ever test several sample(at least therr) yourself?
  	3.Can you promise that the solution is right? At least,the main ideal
  	4.use the puts("") or putchar() or printf and such things?
  	5.init the used array or any value?
  	6.use error MAX_VALUE?
  	7.use scanf instead of cin/cout?
  	8.whatch out the detail input require
*/
/*
    一定在这里写完思路再敲代码!!!
*/
#include <bits/stdc++.h>
using namespace std;

const int N = 50;

int n;
char idx[N+10];

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);
	for (int i = 1;i <= N;i++)
        if (i <= 26){
            idx[i] = 'a'+i-1;
        }else{
            idx[i] = 'A'+i-26-1;
        }
    int kase = 0;
    while (cin >> n){
        if (kase>0) cout << endl;
        kase++;
        cout << 2 <<' '<<n << ' '<<n<<endl;
        for (int i = 1;i <= n;i++){
            for (int j = 1;j <= n;j++)
                cout << idx[i];
            cout<<endl;
        }
        cout << endl;

        for (int i = 1;i <= n;i++)
        {
            for (int j = 1;j <= n;j++)
                cout << idx[j];
            cout << endl;
        }
    }
	return 0;
}

原文地址:https://www.cnblogs.com/AWCXV/p/8179299.html