题解
2025-10-16 20:49:36
发布于:浙江
1阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,a,z,m;
char c;
cin>>n>>c;
a=n;z=0;m=n2-3;
for(int i=1;i<n2;i++){
if(i<=n){
for(int j=1;j<a;j++)
cout<<" ";
cout<<"*";
for(int j=1;j<=z;j++)
cout<<" ";
if(i!=1)cout<<"*";
cout<<endl;
}
else{
for(int j=0;j<=a;j++)
cout<<" ";
cout<<"*";
for(int j=1;j<=z;j++)
cout<<" ";
if(i!=n*2-1)cout<<"*";
cout<<endl;
}
if(i==1){a--;z++;}
else if(i<=n){a--;z+=2;}
else if(i<n*2-1){a++;z-=2;}
else{a++;z--;}
if(i==n)z-=4;
}
return 0;
}
这里空空如也

有帮助,赞一个