简单题解C++
2025-10-07 21:09:29
发布于:浙江
84阅读
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;
}
}
全部评论 1
你写的有点长,可以在简短一点
2025-12-01 来自 广东
0哈哈
6天前 来自 广东
0









有帮助,赞一个