Advertisement
satriafu5710

Membuat Pola Ketupat C++

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