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 << '\n'; } } }
标签:CBABCDE,int,字母,ABCDEFG,BABCDEF,1440,SDNU,include,图形 来源: https://www.cnblogs.com/RootVount/p/10351774.html