Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <vector>
- #include <iostream>
- std::vector<std::string> towerBuilder(unsigned nFloors) {
- std::vector<std::string> piramid;
- for (unsigned int i = 0; i < nFloors; i++){
- piramid[i].append(nFloors/2-1-i, ' ');
- piramid[i].append(i*2+1, '*');
- piramid[i].append(nFloors/2-1-i, ' ');
- };
- return piramid;
- }
- int main(){
- std::vector<std::string> result;
- unsigned x;
- std::cin >> x;
- result = towerBuilder(x);
- for (int i=0; i < x; i++)
- std::cout << result[i] << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement