#include <string>
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
int n;
char c;
cin >> n >> c;
int l;
for(int i=0;i<=n+1;i++){
if((i*i*2-1)>n){
l=i-1;
break;
}
}
for (int i=l;i>0;i--){
for(int j=i;j<l;j++){
printf(" ");
}
for(int j=0;j<2*i-1;j++){
printf("%c",c) ;
}
printf("\n");
}
for (int i=1;i<l;i++){
for(int j=l-i;j>1;j--){
printf(" ");
}
for(int j=2*i+1;j>=1;j--){
printf("%c",c);
}
printf("\n");
}
cout << n-(l*l*2-1);
return 0;
}
B1027 打印沙漏 (20分)
猜你喜欢
转载自blog.csdn.net/WeDon_t/article/details/105302597
今日推荐
周排行