Advertisement
Angga_Wahyu

C++ Program to Print Star Pyramid Patterns Part 1

Oct 16th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n;
  7.    
  8.     cout<<"Masukkan Jumlah : ";
  9.     cin>>n;
  10.    
  11.     cout<<"Pola 1\n";
  12.     for (int i=1; i <= n; i++){
  13.         for(int j=1; j <= i; j++){
  14.             cout<<"*";
  15.         }
  16.         cout<<endl;
  17.     }
  18.     cout<<"Pola 2\n";
  19.     for (int i=1; i <= n; i++){
  20.         for(int j=n; j >= i; j--){
  21.             cout<<"*";
  22.         }
  23.         cout<<endl;
  24.     }
  25.     cout<<"Pola 3\n";
  26.     for (int i=1; i <= n; i++){
  27.         for(int j=1; j < i; j++){
  28.             cout<<" ";
  29.         }
  30.         for(int k=n; k >= i; k--){
  31.             cout<<"*";
  32.         }
  33.         cout<<endl;
  34.     }
  35.     cout<<"Pola 4\n";
  36.     for (int i=1; i <= n; i++){
  37.         for(int j=n; j > i; j--){
  38.             cout<<" ";
  39.         }
  40.         for(int k=1; k <= i; k++){
  41.             cout<<"*";
  42.         }
  43.         cout<<endl;
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement