Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void rect (char c , int nlinhas , int ncolunas)
- {
- int i , j ;
- for (i = 0 ; i < ncolunas ; i++) printf ("%c" , c) ;
- printf ("\n") ;
- for (i = 0 ; i < nlinhas - 2 ; i++)
- {
- for (j = 0 ; j < ncolunas ; j++)
- if (j == 0 || j == ncolunas - 1) printf ("%c" , c) ;
- else printf (" ") ;
- printf ("\n") ;
- }
- for (i = 0 ; i < ncolunas ; i++) printf ("%c" , c) ;
- printf ("\n") ;
- }
- int main ()
- {
- char c ;
- int nlinhas , ncolunas ;
- printf ("Introduza um caracter: ") ;
- scanf ("%c" , &c) ;
- printf ("Introduza o numero de linhas: ") ;
- scanf ("%d" , &nlinhas) ;
- printf ("Introduza o numero de colunas: ") ;
- scanf ("%d" , &ncolunas) ;
- rect(c , nlinhas , ncolunas) ;
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment