Guest User

Untitled

a guest
Jun 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void desenha(char letra, int linhas, int colunas)
  4. {
  5.     for(int i = 0; i < colunas; i++)
  6.     {
  7.  
  8.         printf(" %c", letra);
  9.         if(linhas == 1)
  10.             break;
  11.     }
  12.  
  13.     printf("\n");
  14.  
  15.     for(int j = 0; j < linhas - 2; j++)
  16.     {
  17.         printf(" %c", letra);
  18.  
  19.         for(int k = 0; k < colunas -1 ; k++)
  20.         {
  21.             printf(" ");
  22.         }
  23.  
  24.         printf(" %c", letra);
  25.  
  26.         printf("\n");
  27.  
  28.  
  29.     }
  30.  
  31.  
  32.     for(int i = 0; i < colunas; i++)
  33.     {
  34.         printf(" %c", letra);
  35.  
  36.     }
  37.       printf("\n");
  38.  
  39. }
  40.  
  41. int main()
  42. {
  43.     char carater;
  44.     int linhas, colunas;
  45.  
  46.     printf("Introduza um carater: ");
  47.     scanf(" %c", &carater);
  48.  
  49.     printf("Introduza as linhas: ");
  50.     scanf("%d", &linhas);
  51.  
  52.     printf("Introduza as colunas: ");
  53.     scanf("%d", &colunas);
  54.  
  55.     desenha(carater, linhas, colunas);
  56.  
  57.     return 0;
  58. }
Add Comment
Please, Sign In to add comment