Advertisement
Aminpro

[ECP1016] In-Lab Assignment Trimester 2 2012 Number 4

Nov 28th, 2012
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. //Feel free to optimize the code and send it to the Facebook page, I'll put your name on it...
  2. //https://www.facebook.com/AminproPastebin
  3.  
  4. #include <stdio.h>
  5.  
  6.  
  7. int main(){
  8.    
  9.     int x;
  10.     int y;
  11.     int i;
  12.     int j;
  13.     int mode;
  14.     char pattern;
  15.    
  16.     printf("Please enter the pattern of interest:");
  17.     scanf("%c", &pattern);
  18.     printf("Please enther the size of the box (Height and Width): ");
  19.     scanf("%d%d", &x, &y);
  20.     printf("Select filling type mode, EMP(0) or ONE(1): ");
  21.     scanf("%d", &mode);
  22.    
  23.     for(i=0;i<y;i++){
  24.         printf("%c", pattern);// 1st row
  25.     }
  26.     printf("\n");
  27.    
  28.     x = x-2;
  29.     y = y-2;
  30.    
  31.     for(j=0;j<x;j++){
  32.         printf("%c", pattern);
  33.        
  34.        
  35.         if(mode != 1){ //start check for mode 0
  36.        
  37.         for(i=0;i<y;i++){
  38.         printf(" ");
  39.         }
  40.         }//End check mode 0
  41.    
  42.         else if (mode = 1){
  43.        
  44.         for(i=0;i<y;i++){
  45.         printf("1");
  46.         }
  47.         }
  48.        
  49.     printf("%c\n", pattern);
  50.     }
  51.  
  52.     y = y +2;
  53.     for(i=0;i<y;i++){
  54.     printf("%c", pattern);
  55.     }
  56.     printf("\n");
  57.    
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement