oke_google

Modul 3.2

Nov 29th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char input[100];
  9.     int baris, kolom, x=0;
  10.     cout<<"Masukan kata = ";
  11.     cin.getline(input,100);
  12.     int angka=strlen(input);
  13.     int start=((angka%2==0) ? angka/2+1 : angka/2+1);
  14.     for(baris=1; baris<=angka*2; baris++){
  15.             int n=0;
  16.         for(kolom=1; kolom<=angka*3; kolom++){
  17.             if(kolom>=angka*2-x && kolom<=angka*2+x){
  18.                 if((baris%2==0 && kolom%2==1)||(baris%2==1 && kolom%2==0)){
  19.                 cout<<((baris>angka) ? input[baris-angka+n] : input[0+n]);
  20.                 n++;}
  21.                 else{
  22.                     cout<<" ";
  23.                 }
  24.             }
  25.             else{
  26.                 cout<<" ";
  27.             }
  28.         }
  29.         cout<<endl;
  30.         ((baris<angka) ? x++ : x--);
  31.     }
  32. }
Add Comment
Please, Sign In to add comment