-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1027.cpp
More file actions
48 lines (42 loc) · 717 Bytes
/
1027.cpp
File metadata and controls
48 lines (42 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main(){
int a;
string b;
cin >> a >> b;
int x=0;
//int i = 0;
//while ((i*i) < (16 + 8 * (a - 1))){
// i++;
//}
for (int j = 0; j < a; j++){
if ((2*j*(j + 2) + 1)>a){
x = j - 1;
break;
}
}
//x = (-4 + i) / 4;
int shen = a - (2 * (x*x) + 4 * x+1);
int *s = new int[2 * x + 1];
for (int j = 0; j <= x; j++)
{
s[j] = 2 * (x - j) + 1;
s[2 * x - j] = s[j];
}
for (int j = 0; j < 2 * x + 1; j++){
if (s[j] < 2 * x + 1){
for (int k = 0; k < (2 * x + 1 - s[j]) / 2;k++)
cout << " ";
}
while (s[j] > 0){
cout << b;
s[j]--;
}
cout << endl;
}
cout << shen;
system("pause");
return 0;
}