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