Problem Description: 44158317
Output Small Stars (5)
1#include"stdafx.h"2 3 intMain ()4 {5 intx, X1;6scanf_s ("%d", &x);7X1 =x;8 9 //Output line 1th (special line)Ten for(inti =0; I < X-1; i++) One { Aprintf" "); - } -printf"*"); theprintf"\ n"); - - //output 2nd to X-1 line - for(inti =1; I < X-1; i++) + { - //Output I line 1th set of spaces + for(inti =1; I < x1-1; i++) A { atprintf" "); - } -x1--; - - //Output I line 1th * -printf"*"); in - //Output I line 2nd set of spaces to for(intj =1; J <=2*i-1; J + +) + { -printf" "); the } * $ //Output I line 2nd *Panax Notoginsengprintf"*"); - the //line Break +printf"\ n"); A the } + - //Output line X (special line) $ for(inti =0; I <2*x-1; i++) $ { -printf"*"); - } theprintf"\ n"); - Wuyi return 0; the}
Results
Output Small Stars (6)
1 intMain ()2 {3 intx, x1, x2;4scanf_s ("%d", &x);5X1 =x;6x2 = x-1;7 8 //input isosceles triangle Upper half (with Midline)9 for(inti =1; I <= x; i++)Ten { One //Output I line space section A for(inti =0; I < x1-1; i++) - { -printf" "); the } -x1--; - - //Output I line * Section + for(intj =0; J <2*i-1; J + +) - { +printf"*"); A } at - //line Break -printf"\ n"); - } - - //enter the lower half of the isosceles triangle in for(inti =1; I <= X-1; i++) - { to //Output I line space section + for(intj =0; J < I; J + +) - { theprintf" "); * } $ Panax Notoginseng //Output I line * Section - for(inti =0; I <2*X2-1; i++) the { +printf"*"); A } thex2--; + - //line Break $printf"\ n"); $ } - - the return 0; -}
Results
Feelings:
Writing "pseudo-code" can increase the readability of code;
"C Language and Programming" Project 1-32-(5) & (6): Output Small stars