答案
2024-04-21 16:31:59
发布于:北京
12阅读
0回复
0点赞
#include <bits/stdc++.h>
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 << " ";
}
if(i == 1){
cout << "*";
}else{
cout << "*";
for(int j = 1; j <= (i - 1) * 2 - 1; j++){
cout << " ";
}
cout << "*";
}
cout << endl;
}
for(int i = n - 1; i >= 1; i--){
for(int j = 1; j <= n - i; j++){
cout << " ";
}
if(i == 1){
cout << "*";
}else{
cout << "*";
for(int j = 1; j <= (i - 1) * 2 - 1; j++){
cout << " ";
}
cout << "*";
}
cout << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个