一级标题 1027 打印沙漏 c++
#include<iostream>
using namespace std;
#include<iomanip>
int main()
{
int sum = 0;cin >> sum;char st;cin >> st;int count = 1;int line=0;if (sum<7){
cout << st << endl;cout << sum - 1;}else{
int i = 3;for (i = 3; i < sum; i+=2){
count += 2*i;line++;if (count > sum){
count -= 2 * i;i -=2; break;}}int j = 0;for (j; j < line; j++){
cout << setw(j) << "";int column = i;for (int a = 0; a < column; a++){
cout << st;}i -= 2; cout<<endl; }j -= 2; i += 4;for (j; j >=0; j--){
cout << setw(j) << "";int column = i;for (int a = 0; a < column; a++){
cout << st;}i += 2;cout << endl;}cout << sum-count;}return 0;
}