Advertisement
betavian18

lolol

Mar 7th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int a, baris, kolom;
  5.     printf("Masukkan ukuran kotak = ");
  6.     scanf("%d", &a);
  7.     for(baris = 1; baris <= a ; baris++){
  8.         for(kolom = 1 ; kolom <= a ; kolom++){
  9.             if( a % 2 == 0){
  10.                 if( (baris == 1 || kolom == 1) ||
  11.                     (baris == a || kolom == a) ||
  12.                     (baris == a/2 || kolom == a/2) ||
  13.                     (baris == (a/2)+1 || kolom == (a/2)+1) )
  14.                      printf("*");
  15.                 else printf(" ");
  16.             }
  17.             else if( (baris == 1 || kolom == 1) ||
  18.                      (baris == a || kolom == a) ||
  19.                      (baris == (a/2)+1 || kolom == (a/2)+1) )
  20.                     printf("*");
  21.                 else printf(" ");
  22.         }printf("\n");
  23.     }
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement