Blue Bridge basic exercises letters graphics BASIC-3

Problem Description

Use of the letters can form some beautiful graphics, an example is given below:

ABCDEFG

BABCDEF

CBABCDE

DCBABCD

EDCBABC

This is a pattern row 5 7, find the pattern of this rule, and outputs a pattern of n rows and m columns.

Input Format

Input line, comprising two integers n and m, respectively represent the number of columns you want output pattern lines.

Output Format

N output lines, each m characters for your graphics.

Sample input

5 7
Sample Output
ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC

Data size and convention

1 <= n, m <= 26。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

#define INF 0x7fffffff
const double inf=1e20;
const int maxn=10000+10;
const int mod=1e9+7;
const double pi=acos(-1);

char a[26][26];

int main(){
    for(int i=0;i<26;i++){
        int k=-i;
        for(int j=0;j<26;j++){
            a[i][j]='A'+abs(k);
            k++;
        }
    }
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            printf("%c",a[i][j]);
        }
        printf("\n");
    }
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/wz-archer/p/12499383.html