oke_google

Modul 3.1

Nov 29th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 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 x=1, baris, kolom;
  10.     cout<<"Masukan Kalimat = ";
  11.     cin.getline(input, 100);
  12.     int angka=((strlen(input)%2==0) ? strlen(input)/2+1 : strlen(input)/2);
  13.     for(baris=0; baris<strlen(input); baris++){
  14.         for(kolom=0; kolom<strlen(input); kolom++){
  15.             if(baris!=0 && (kolom>=angka-x && kolom<=angka+x)){
  16.             cout<<"  ";
  17.             }
  18.             else{
  19.                 cout<<input[baris]<<" ";
  20.             }
  21.         }
  22.         cout<<endl;
  23.         ((baris!=0 && baris<((strlen(input)%2==0) ? strlen(input)/2+1 : strlen(input)/2)) ? x++ : x--);
  24.     }
  25. }
Add Comment
Please, Sign In to add comment