题目描述
打印 n 阶实心菱形
输入描述输入一个整数n,n<=10
输出描述输出 n 阶实心菱形 , 占 2*n-1 行
样例输入3样例输出
*提交代码
***
*****
***
*
/* students please write your program here*/ #include <iostream> using namespace std; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n - i; j++) cout << " " ; for (int j = 1; j <= 2 * i - 1; j++) cout << "*"; cout <<endl; } for (int i = n - 1; i >= 1; i--) { for (int j = 1; j <= n - i; j++) cout << " "; for (int j = 1; j <= 2 * i - 1; j++) cout << "*"; cout << endl; } }