Basic Practice Letter Graphics time limit: 1.0s memory Limit: 256.0MB problem description
Using letters to make some beautiful graphics, here's an example:
ABCDEFG
Babcdef
Cbabcde
Dcbabcd
Edcbabc
This is a 5 row 7-column graph, find out the pattern of the graph, and output an n-row m-column graph. Input format enter a line containing two integers n and m, each representing the number of columns of the number of rows 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 size and conventions 1 <= N, M <= 26. Ac-code:
#include <cstdio>
#include <cstring>
int main ()
{
int n,m,i,j,flag;
scanf ("%d%d", &n,&m);
for (i=0;i<n;i++)
{
for (j=i,flag=0;j>0&&flag<m;j--, flag++)
printf ("%c", ' A ' +j);
for (j=0;j<m-i;j++)
printf ("%c", ' A ' +j);
printf ("\ n");
}
return 0;
}