题解
2023-09-05 23:32:32
发布于:浙江
10阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >>a;
int b=a-1;
int c=0;
int sum=0;
for(int i =1;i<a;i++){
sum+=2;
}
bool anm=0;
for(int i =1;i<=a;i++){
for(int j=1;j<=b;j++){
cout <<" ";
}
cout <<"*";
for(int j=1;j<=c-1;j++){
cout <<" ";
}
if(i!=1){
cout <<"*";
}
c+=2;
cout <<endl;
b--;
}
int d=1,n=sum-3;
for(int i=1;i<=a-1;i++){
for(int j=1;j<=d;j++){
cout <<" ";
}
cout <<"*";
for(int j=1;j<=n;j++){
cout <<" ";
}
if(i!=a-1){
cout <<"*";
}
d++;
cout <<endl;
n-=2;
}
return 0;
}
这里空空如也
有帮助,赞一个