教程来啦,可以参考(做的有点麻烦)
2025-12-01 19:25:27
发布于:广东
14阅读
0回复
0点赞
#include<iostream>
using namespace std;
int main() {
int n;
char c;
cin>>n>>c;
for (int i=1;i<=n;i++) {
for (int j=0;j<n-i;j++) {
cout<<" ";
}
for(int j=0;j<2i-1;j++) {
if (j0||j2i-2) {
cout<<c;
}else{
cout<<" ";
}
}
cout<<endl;
}
for(int i=n-1;i>=1;i--) {
for (int j=0;j<n-i;j++) {
cout<<" ";
}
for(int j=0;j<2i-1;j++){
if (j0||j2i-2){
cout<<c;
}else{
cout<<" ";
}
}
cout<<endl;
}
return 0;
}
这里空空如也

有帮助,赞一个