Created
March 8, 2019 22:07
-
-
Save Silva97/0d7cfd0ef8ae19d8d74b654367d35997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
enum { | |
RECT_T = '-', // Aresta do topo | |
RECT_TR = '+', // Vértice do canto superior direito | |
RECT_R = '|', // Aresta da direita | |
RECT_BR = '+', // Vértice do canto inferior direito | |
RECT_B = '-', // Aresta da parte inferior | |
RECT_BL = '+', // Vértice do canto inferior esquerdo | |
RECT_L = '|', // Aresta da esquerda | |
RECT_TL = '+', // Vértice do canto superior esquerdo | |
RECT_C = ' ' // Preenchimento do retângulo | |
}; | |
void putmchar(int c, int times); | |
void printrect(int width, int height); | |
int main(){ | |
printrect(7, 5); | |
return 0; | |
} | |
void printrect(int width, int height){ | |
for(int i = 0; i < height; i++){ | |
if(!i){ | |
putchar(RECT_TL); | |
putmchar(RECT_T, width); | |
putchar(RECT_TR); | |
putchar('\n'); | |
} else if(i == height-1){ | |
putchar(RECT_BL); | |
putmchar(RECT_B, width); | |
putchar(RECT_BR); | |
} else { | |
putchar(RECT_L); | |
putmchar(RECT_C, width); | |
putchar(RECT_R); | |
putchar('\n'); | |
} | |
} | |
} | |
void putmchar(int c, int times){ | |
for(int i = 0; i < times; i++) | |
putchar(c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment