• SDNU 1440.字母图形


    Description

    利用字母可以组成一些美丽的图形,下面给出了一个例子:
    ABCDEFG
    BABCDEF
    CBABCDE
    DCBABCD
    EDCBABC
    这是一个5行7列的图形,请找出这个图形的规律,并输出一个n行m列的图形。

    Input

    输入一行,包含两个整数n和m,分别表示你要输出的图形的行数的列数。 

    Output

    输出n行,每个m个字符,为你的图形。

    Sample Input

    5  7

    Sample Output

    ABCDEFG
    BABCDEF
    CBABCDE
    DCBABCD
    EDCBABC

    Hint

    数据规模与约定 1  < =  n,  m  < =  26。
    #include <cstdio>
    #include <iostream>
    using namespace std;
    
    char ar[27][28] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
                       "BABCDEFGHIJKLMNOPQRSTUVWXY",
                       "CBABCDEFGHIJKLMNOPQRSTUVWX",
                       "DCBABCDEFGHIJKLMNOPQRSTUVW",
                       "EDCBABCDEFGHIJKLMNOPQRSTUV",
                       "FEDCBABCDEFGHIJKLMNOPQRSTU",
                       "GFEDCBABCDEFGHIJKLMNOPQRST",
                       "HGFEDCBABCDEFGHIJKLMNOPQRS",
                       "IHGFEDCBABCDEFGHIJKLMNOPQR",
                       "JIHGFEDCBABCDEFGHIJKLMNOPQ",
                       "KJIHGFEDCBABCDEFGHIJKLMNOP",
                       "LKJIHGFEDCBABCDEFGHIJKLMNO",
                       "MLKJIHGFEDCBABCDEFGHIJKLMN",
                       "NMLKJIHGFEDCBABCDEFGHIJKLM",
                       "ONMLKJIHGFEDCBABCDEFGHIJKL",
                       "PONMLKJIHGFEDCBABCDEFGHIJK",
                       "QPONMLKJIHGFEDCBABCDEFGHIJ",
                       "RQPONMLKJIHGFEDCBABCDEFGHI",
                       "SRQPONMLKJIHGFEDCBABCDEFGH",
                       "TSRQPONMLKJIHGFEDCBABCDEFG",
                       "UTSRQPONMLKJIHGFEDCBABCDEF",
                       "VUTSRQPONMLKJIHGFEDCBABCDE",
                       "WVUTSRQPONMLKJIHGFEDCBABCD",
                       "XWVUTSRQPONMLKJIHGFEDCBABC",
                       "YXWVUTSRQPONMLKJIHGFEDCBAB",
                       "ZYXWVUTSRQPONMLKJIHGFEDCBA"};
    int main () {
        int n, m;
        while (scanf("%d %d", &n, &m) != EOF) {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    cout << ar[i][j];
                }
                cout << '
    ';
            }
        }
    }
  • 相关阅读:
    家庭问题(family)
    BFS简单题记
    【例2-3】围圈报数
    【例8.3】最少步数
    【例3-5】扩展二叉树
    股票买卖
    小球(drop)
    用循环单链表实现约瑟夫环
    二叉树的3种遍历6种实现
    const与#define宏常量 , inline与#define
  • 原文地址:https://www.cnblogs.com/RootVount/p/10351774.html
Copyright © 2020-2023  润新知