Advertisement
Jvsierra

Ex quadro

Aug 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define TFL 20
  4. #define TFC 20
  5.  
  6. void desenha(int x1, int y1, int x2, int y2);
  7.  
  8. int main(void)
  9. {
  10.     int x1, x2, y1, y2;
  11.    
  12.     scanf("%d %d", &x1, &y1);
  13.     scanf("%d %d", &x2, &y2);
  14.    
  15.     desenha(x1, y1, x2, y2);
  16. }
  17.  
  18. void desenha(int x1, int y1, int x2, int y2)
  19. {
  20.     int l, c, mat[TFL][TFC];
  21.    
  22.     for(l = 0; l < TFL; l++)
  23.         for(c = 0; c < TFC; c++)
  24.             mat[l][c] = 0;
  25.    
  26.     for(c = y1 - 1; c < y2; c++)
  27.         mat[x1 - 1][c] = 1;
  28.        
  29.     for(l = x1; l < x2 - 1; l++)   
  30.     {
  31.         mat[l][y1 - 1] = 1;
  32.         mat[l][y2 - 1] = 1;
  33.     }
  34.    
  35.     for(c = y1 - 1; c < y2; c++)
  36.         mat[x2 - 1][c] = 1;
  37.        
  38.     for(l = x1 - 1; l < x2; l++)
  39.     {
  40.         for(c = y1 - 1; c < y2; c++)
  41.         {
  42.             if(mat[l][c] == 1)
  43.                 printf("|");
  44.             else
  45.                 printf(" ");
  46.         }
  47.    
  48.         printf("\n");  
  49.     }  
  50.    
  51.     printf("\n\n\n");
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement