Blue Bridge Cup - Basic Training 03-- letter graphics

Graphic letter :

Problems described
using letters may be composed of 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 line pattern.
Output format
output n lines, each m characters, for your pattern.
Input Sample
57
Sample Output
ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC
data size and Conventions
1 <= n, m <= 26.

Is the way to see how the code below:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	char a, b;
	int i, j, n, m;
	
	scanf("%d %d",&n, &m);
	if(n>=1 && m<=26){
		for(i=0; i<n; i++){
			for (a='A'+i; a>'A'; a--)
				printf("%c",a);
			for (b='A'; b<'A'+m-i; b++)
				printf("%c",b); 
									
			printf("\n");
			}
	}
	return 0;
}

Look at Code II:

#include <stdio.h>
#include<stdio.h> 
char zimubiao[26]={'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 main()
{
	int n,m;
	int i, j;
	scanf("%d %d",&n,&m);
	for(i=1; i<=n; ++i)
		{
			for(j=1;j<=m;++j)
			{
				if(j<i)
				  printf("%c",zimubiao[i-j]);
				else
				  printf("%c",zimubiao[j-i]);
			}
			printf("\n");
		} 
	return 0;
}

There is also a yo ~ This is from the Internet to see, feel good, come by to learn about:

#include<stdio.h>
#include<math.h>
int main()
{
    int m,n;
    scanf("%d%d",&n,&m);
    int i,j;
    for(i=0;i<n;i++)
    {
         for(j=0;j<m;j++)
         {
              printf("%c",65+abs(i-j)); 
         }
         printf("\n");
    } 
   return 0;
}

Well -
this way, and quickly learn to go! ! ! Come on ~

Guess you like

Origin blog.csdn.net/weixin_44566432/article/details/88733584