Test questions basic practice letter graphics (C language)

BABCDEF

CBABCDE

DCBABCD

EDCBABC

This is a graph with 5 rows and 7 columns. Please find out the pattern of this graph and output a graph with n rows and m columns.

Input format

Enter a row, containing two integers n and m, respectively representing the number of rows and columns of the graph you want to output.

Output format

Output n lines, each m characters, for your graphics.

Sample input

5 7

Sample output

ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC

Data scale and convention

1 <= n, m <= 26。

BABCDEF

CBABCDE

DCBABCD

EDCBABC

This is a graph with 5 rows and 7 columns. Please find out the pattern of this graph and output a graph with n rows and m columns.

Input format

Enter a row, containing two integers n and m, respectively representing the number of rows and columns of the graph you want to output.

Output format

Output n lines, each m characters, for your graphics.

Sample input

5 7

Sample output

ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC

Data scale and convention

1 <= n, m <= 26。

 

#include<bits/stdc++.h>
using namespace std;

int main()
{
	char s[30]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int i,j,k;
	int n,m;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			printf("%c",s[abs(i-j)]);
			
		}
		printf("\n");
	}
	
	
	
	
	return 0;
}

Just type the letters directly into the table and find out the relationship between the first few rows and columns and the corresponding letters .

Guess you like

Origin blog.csdn.net/with_wine/article/details/114978837