Problem B: Print letter Diamond pattern Time limit: 1 Sec Memory Limit: MB
Submit: 2530 Solved: 1769
[Submit] [Status] [Web Board] Description
Output n (odd n) lines consist of letters of the Diamond, the 1th act the letter A, the 2nd Act BCD, the third act CDEFG, and so on. The diamond is symmetrical up and down.
Input
An odd n. 0<n<18.
Output
A diamond pattern consisting of n-line letters.
Sample Input7Sample OutputABCDCDEFGDefghijCDEFGBCDAHintappend Code
In fact, the simple pyramid output, only different when the first letter of each line has changed, so as long as the focus on this point is good.
1#include <stdio.h>2#include <math.h>3#include <string.h>4#include <ctype.h>5 intMain ()6 {7 intm;8scanf"%d",&m);9 inti,j;Ten intK; One for(j=0;j< (m+1)/2; j + +) A { - for(i=0;i< (m+1)/2-1-j;i++) -printf" "); the for(k=j;k<j*3+1; k++) -printf"%c",'A'+k); -printf"\ n"); - } + for(J= (m+1)/2-2; j>=0; j--) - { + for(I= (m+1)/2-2-j;i>=0; i--) Aprintf" "); at for(k=j;k<j*3+1; k++) -printf"%c",'A'+k); -printf"\ n"); - } - -}
Sdustoj Print Letter Diamond pattern