Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cout << "How big do you want your tree?(up to 18)";
- cin >> n;
- int spaces = 20;
- int stars = 1;
- for(int i = 1; i <= n; i++){
- for(int a = 1; a <= spaces; a++){
- cout << " ";
- }
- for(int b = 1; b <= stars; b++){
- cout << "*";
- }
- cout << "\n";
- spaces -= 1;
- stars += 2;
- }
- spaces = 19;
- stars = 3;
- for(int i = 1; i <= n; i++){
- for(int a = 1; a <= spaces; a++){
- cout << " ";
- }
- for(int b = 1; b <= stars; b++){
- cout << "*";
- }
- cout << "\n";
- spaces -= 1;
- stars += 2;
- }
- spaces = 18;
- stars = 5;
- for(int i = 1; i <= n + 1; i++){
- for(int a = 1; a <= spaces; a++){
- cout << " ";
- }
- for(int b = 1; b <= stars; b++){
- cout << "*";
- }
- cout << "\n";
- spaces -= 1;
- stars += 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement