Written by Bruth_Lee in Southwest universiy of Science and Technology.
制作一个这样简单的沙漏吧!
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int i,j, n, N;
char a;
while (cin >> N >> a)
{
n = sqrt((N + 1) / 2);
int m = n;
int count = 2 * m - 1;
int c = 0;
for (i = 0; i < 2 * n - 1; i++)
{
int count = 2 * m - 1;
for (j = 0; j < n - m; j++)//输出空格
{
cout << " ";
}
for (j = 0; j <count; j++)//输出字符
{
cout << a;
}
cout << endl;
c++;
if (c<n) m--;
else m++;
}
cout << N - (2 * n*n - 1) << endl;
}
return 0;
}