Problem Description
There are some beautiful shapes that can be formed using letters, an example is given below:
ABCDEFG
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
Input a line, containing two integers n and m, which respectively represent the number of rows and columns of the graph you want to output.
output format
Output n lines, m characters each, for your graph.
sample input
5 7
Sample output
ABCDEFG
BABCDEF
CBABCDE
DCBABCD
EDCBABC
BABCDEF
CBABCDE
DCBABCD
EDCBABC
Data size and convention
1 <= n, m <= 26。
#include <stdio.h> #include<math.h> #include<limits.h> char a[26] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; intmain() { int m, n, i, j; scanf("%d%d", &m, &n); for(i=0; i<m; i++){ for(j=0; j<n-1; j++) { printf("%c", a[abs(i-j)]); } printf("%c\n", a[abs(j-i)]); } return 0; }Only 70 points were submitted at the beginning,,, I forgot to consider the case that i is larger than j,,, o( ̄ヘ ̄o#) I looked at the test data and tested it before I saw it, I used abs,, be careful, ,,