Basic exercise letter Graphics of the Blue Bridge cup [classic character questions], Blue Bridge graphics
Basic exercise letter graphics time limit: 1.0 s memory limit: 256.0 MB Problem description
Using letters to make up some beautiful images, the following is an example:
ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC
This is a graph with 5 rows and 7 columns. Please find out the pattern and output a graph with n rows and m columns.
Enter a row in the input format, which contains two integers n and m, indicating the number of rows in the graph you want to output. The output format outputs n rows, each of which is m characters for your graphics. Sample input 5 7 sample output ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC data scale and conventions 1 <= n, m <= 26.
#include<stdio.h>char str[30][30];int main(){int i,j,n,m;while(~scanf("%d%d",&n,&m)){int k,flag=0;for(i=0;i<n;i++){k=i,flag=0;for(j=0;j<m;j++){if(k==0)flag=1;str[i][j]='A'+k;flag?k++:k--;printf("%c",str[i][j]);}printf("\n");}}return 0;}