annasgtg

diamond

Feb 12th, 2018
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.     int n, c, k, spasi=1;
  9.     cout<<"Masukkan Dimensi Diamond : ";
  10.     cin>>n;
  11.     spasi=n-1;
  12.     for (k=1; k<=n; k++)
  13.     {
  14.     for(c=1; c<=spasi; c++)
  15.     {
  16.         cout<<" ";
  17.     }
  18.     spasi--;
  19.     for(c=1; c<=(2*k-1); c++)
  20.     {
  21.         cout<<"*";
  22.     }
  23.     cout<<"\n";
  24.     }
  25.     spasi=1;
  26.     for(k=1; k<=(n-1); k++)
  27.     {
  28.     for(c=1; c<=spasi; c++)
  29.     {
  30.         cout<<" ";
  31.     }
  32.     spasi++;
  33.     for(c=1 ; c<=(2*(n-k)-1); c++)
  34.     {
  35.         cout<<"*";
  36.     }
  37.     cout<<"\n";
  38.     }
  39.     getch();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment