-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstairCase.cpp
More file actions
35 lines (23 loc) · 766 Bytes
/
stairCase.cpp
File metadata and controls
35 lines (23 loc) · 766 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
#include <bits/stdc++.h>
using namespace std;
// Complete the staircase function below.
void staircase(int n) {
int space, symbols = 1, buildStaircase;
buildStaircase = n - 1; // start at top and there are n-1 tabs
for (int i = 0; i < n; i++) {
space = buildStaircase;
for (int tabs = 0; tabs < space; tabs++) cout << " " ; // loop one time through at a time and each time space decreases
for (int hashTags = 0; hashTags < symbols; hashTags++) cout << "#"; // loop one time through at a time and up no symbols
cout << endl;
buildStaircase--;
symbols++;
}
}
int main()
{
int n;
cin >> n;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
staircase(n);
return 0;
}