-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuildTower.cpp
More file actions
62 lines (56 loc) · 1.19 KB
/
BuildTower.cpp
File metadata and controls
62 lines (56 loc) · 1.19 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> towerBuilder(unsigned nFloors) {
vector<string>result;
string prive1 = "*";
string prive2 = "**";
string sum;
result.push_back("*");
for (int i = 1; i < nFloors; i++)
{
sum = (prive1 + prive2);
prive1 = prive2;
prive2 = sum;
result.push_back(sum);
}
return result;
}
int main()
{
towerBuilder(3); // 3 return 0;
}
/*Description:
Build Tower
Build a pyramid-shaped tower, as an array/list of strings, given a positive integer number of floors. ]
A tower block is represented with "*" character.
For example, a tower with 3 floors looks like this:
[
" * ",
" *** ",
"*****"
]
And a tower with 6 floors looks like this:
[
" * ",
" *** ",
" ***** ",
" ******* ",
" ********* ",
"***********"
]
Go challenge Build Tower Advanced once you have finished this :)
Strings
ASCII Art
Fundamentals*/
// /> フ
// | n n 彡
// /`ミ_xノ
// / |
// / ヽ ノ
// │ | | |
// / ̄| | | |
// | ( ̄ヽ__ヽ_)__)
// \二つ
// ITS CAT FOR YOU