#include<iostream>
using namespace std;
int main(){
int n;
char c;
cin>>n>>c;
int row=0,sum=0;
while(2*sum-1<=n){
row++;
sum=row+row*(row-1)*2/2;
}
row--;
for(int i=0;i<row;i++){
for(int j=row;j>row-i;j--) cout<<" ";
for(int j=2*row-1;j>2*i;j--) cout<<c;
cout<<endl;
}
for(int i=row-2;i>=0;i--){
for(int j=row;j>row-i;j--) cout<<" ";
for(int j=2*row-1;j>2*i;j--) cout<<c;
cout<<endl;
}
cout<<n-(2*row*row-1)<<endl;
return 0;
}
PAT乙级-1027 打印沙漏(20 分)
最新推荐文章于 2024-08-22 17:27:46 发布