-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1027.cpp
More file actions
37 lines (37 loc) · 680 Bytes
/
Copy path1027.cpp
File metadata and controls
37 lines (37 loc) · 680 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
#include <iostream>
using namespace std;
void print( int n, char c) {
for( int i = 0; i <( n + 1 )/ 2; ++i) {
for( int j = 0; j < i; ++j)
cout << " ";
for( int j = 0; j < n - i * 2; ++j)
cout << c;
cout << endl;
}
for( int i = 1; i <( n + 1 )/ 2; ++i) {
int t =( n - i)/ 2;
for( int j = 0; j < ( n - 1 )/ 2 - i; ++j)
cout << " ";
for( int j = 1; j <= 2 * i + 1; ++j)
cout << c;
cout << endl;
}
}
int main() {
int n;
char c;
cin >> n >> c;
int temp;
for( int i = 1, sum, flag = 0;; i += 2) {
sum = ( i * i + 2 * i - 1 )/ 2;
if( n < sum) {
flag = 1;
n = i-2;
break;
}
temp = n - sum;
}
print(n, c);
cout << temp;
return 0;
}