1.打印 * 型菱形
/*------------------------
功能:打印*菱形
运行结果为:
*
***
*****
*******
*****
***
*
--------------------------
Author: Zhang Kaizhou
Date: 2019-3-26 16:54:17
-------------------------*/
#include <iostream>
using namespace std;
int main(){
for(int i = 1; i <= 4; i++){ // 上半三角
for(int j = 1; j <= 4 - i; j++){ // 打印空格
cout << ' ';
}
for(int j = 1; j <= 2 * i - 1; j++){ // 打印*号
cout << '*';
}
cout << endl;
}
for(int i = 1; i <= 3; i++){ // 下半三角
for(int j = 1; j <= i; j++){ // 打印空格
cout << ' ';
}
for(int j = 1; j <= 7 - 2 * i; j++){ // 打印*号
cout << '*';
}
cout << endl;
}
return 0;
}
2.打印字母菱形</