题解
2025-07-11 11:03:24
发布于:江西
25阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int s,a,n=1,count=0;
char c;
cin>>s>>c;
while(a-1<=s){
a+=n*2;
n+=2;
}
n-=4;
for(int i=0;i<n/2;i++){
for(int j=0;j<i;j++) cout<<' ';
for(int j=0;j<n-2*i;j++){
cout<<c;
count++;
}
cout<<endl;
}
for(int i=n/2;i>=0;i--){
for(int j=i;j>0;j--) cout<<' ';
for(int j=n-2*i;j>0;j--){
cout<<c;
count++;
}
cout<<endl;
}
cout<<s-count;
return 0;
}
全部评论 1
有没有大佬有别的解法
2025-07-11 来自 江西
1有的话发在下面
2025-07-11 来自 江西
1感觉挺好的
4天前 来自 浙江
0
有帮助,赞一个