-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_B1036.cpp
More file actions
48 lines (43 loc) · 707 Bytes
/
3_B1036.cpp
File metadata and controls
48 lines (43 loc) · 707 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
/**
* P89 画正方形
*/
#include <iostream>
using namespace std;
/**
* n: column number
*/
void drawFunc(int n)
{
int col = n;
int row = col % 2 == 0 ? col / 2 : (col / 2) + 1;
// 1st row
for (int i = 0; i < col; i++)
{
cout << "a";
}
cout << endl;
// 2nd ~ (row-1)th rows
for (int j = 0; j < row - 2; j++)
{
cout << "a";
for (int k = 0; k < col - 2; k++)
{
cout << " ";
}
cout << "a" << endl;
}
// last row
for (int l = 0; l < col; l++)
{
cout << "a";
}
cout << endl;
}
int main()
{
int n;
cout << "Input n: ";
cin >> n;
drawFunc(n);
return 0;
}