oke_google

Modul 3.8

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