码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-01-02 23:23:59      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:c++   amp   elf   solution   array   pos   else   ble   print   

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


在这里输入题意

【题解】


两层 然后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;
}

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

标签:c++   amp   elf   solution   array   pos   else   ble   print   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!