简单题解C++
2025-10-07 21:09:29
发布于:浙江
5阅读
0回复
0点赞
#include<iostream>
using namespace std;
int main()
{
long long n,a,b;
char c;
cin>>n>>c;
a=n-1;
b=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=a;j++)
{
cout<<" ";
}
for(int j=1;j<=b;j++)
{
cout<<c;
}
for(int j=1;j<=a;j++)
{
cout<<" ";
}
cout<<endl;
a=a-1;
b=b+2;
}
a=a+1;
b=b-2;
for(int i=1;i<n;i++)
{
a=a+1;
b=b-2;
for(int j=1;j<=a;j++)
{
cout<<" ";
}
for(int j=1;j<=b;j++)
{
cout<<c;
}
for(int j=1;j<=a;j++)
{
cout<<" ";
}
cout<<endl;
}
}
这里空空如也
有帮助,赞一个