Angga_Wahyu

C++ Program to Print Star Pyramid Patterns Part 2

Oct 16th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 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 5\n";
  12.    
  13.     for(int i=1; i <= n; i++){
  14.         for(int j=n; j > i; j--){
  15.         cout<<" ";
  16.         }
  17.     for(int k=1; k <= (2*i-1); k++){
  18.         cout<<"*";
  19.     }
  20.     cout<<endl;
  21.     }
  22.     cout<<"Pola 6\n";
  23.    
  24.     for(int i=1; i <= n; i++){
  25.         for(int j=1; j < i; j++){
  26.         cout<<" ";
  27.         }
  28.     for(int k=n; k >= (2*i-n); k--){
  29.         cout<<"*";
  30.     }
  31.     cout<<endl;
  32.     }
  33.     cout<<"Pola 7\n";
  34.    
  35.     for(int i=1; i <= n; i++){
  36.         for(int j=n; j > i; j--){
  37.         cout<<" ";
  38.         }
  39.     for(int k=1; k <= (2*i-1); k++){
  40.         cout<<"*";
  41.     }
  42.     cout<<endl;
  43.     }
  44.     for(int i=2; i <= n; i++){
  45.         for(int j=1; j < i; j++){
  46.         cout<<" ";
  47.         }
  48.     for(int k=n; k >= (2*i-n); k--){
  49.         cout<<"*";
  50.     }
  51.     cout<<endl;
  52.     }
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment