This repository has been archived on 2024-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
lessons/C++/lesson2/task8.cpp
2023-07-16 13:23:25 +00:00

37 lines
982 B
C++

#include <iostream>
#include <string>
int main() {
int height;
std::cin >> height;
std::string value = std::string();
for (int count = height - 1; count >= 0; count--) {
value.clear();
for (int j = 0; j < count; j++) {
value.push_back(' ');
}
int limit = height * 2 - 1 - count * 2;
for (int j = 0; j < limit; j++) {
value.push_back('*');
}
for (int j = 0; j < count; j++) {
value.push_back(' ');
}
std::cout << value << '\n';
}
for (int count = 1; count < height; count++) {
value.clear();
for (int j = 0; j < count; j++) {
value.push_back(' ');
}
int limit = height * 2 - 1 - count * 2;
for (int j = 0; j < limit; j++) {
value.push_back('*');
}
for (int j = 0; j < count; j++) {
value.push_back(' ');
}
std::cout << value << '\n';
}
}