Problem Description
Enter n, and the output corresponds to a hollow positive hexagon with a side length of N.
For easy viewing, the sample midpoint '. ' Represents a space and prints a space instead of a small dot when plotting a drawing.
Input
Edge length N. (N<=20)
Output
Side length is a positive hexagon of n
Sample Input
5
Sample Output
.....*****....*.....*...*.......*.. *.........*.*...........*.. *.........*...*.......*....*.....*.....*****
1#include <stdio.h>2#include <math.h>3 voidPrtCharCintcount)4 { 5 while(count--) 6 { 7printf"%c", c); 8 } 9 } Ten One intMain () A { - intN, L; - while(SCANF ("%d", &n)! =EOF) the { - if(n>0&& n<= -) - { -L=0; + for(; L <2N1; l++) - { +Prt' ',1); APrt' ', ABS (n-l-1)); at - if(0= = L | | L = =2N2) - { -Prt'*', N); - } - Else in { -Prt'*',1); toPrt' ',3N4-(ABS (L +1-N) *2)); +Prt'*',1); - } theprintf"\ n"); * } $ } Panax Notoginseng } - return 0; the}
Wuhan University of Science and Technology acm:1001: Chinese Edition C language Programming tutorial (second Edition) after class exercise 3.12