C/C++ 언어 원하는 위치에 사각형 그리기 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <windows.h>
#include <conio.h>
#include <stdio.h>
 
#define UL 1 // UpLeft 
#define UR 2 // UpRight
#define DL 3 // DownLeft
#define DR 4 // DownRight
#define HE 5 // Height
#define WI 6 // Width
 
HANDLE ghOutput;
 
void Pustchxy(int,int,int);
 
int main() {
  int i = 0, j = 0;
  int max_i = 0, max_j = 0;
  int temp_i = 0, temp_j = 0;
 
  printf("그리고 싶은 위치를 입력하시오 (X Y) : ");
  scanf("%d %d",&i,&j);
 
  temp_i = i;
  temp_j = j;
 
  max_i = 29 + i;
  max_j = 9 + j;
 
  ghOutput = GetStdHandle(STD_OUTPUT_HANDLE);
 
  for(i = i+1;i < max_i;i++) {
    Pustchxy(i,temp_j,WI);
    Pustchxy(i,max_j,WI);
  }
 
  for(j = j+1;j < max_j;j++) {
    Pustchxy(temp_i,j,HE);
    Pustchxy(max_i,j,HE);
  }
 
  Pustchxy(temp_i,temp_j,UL);
  Pustchxy(max_i,temp_j,UR); 
  Pustchxy(temp_i,max_j,DL); 
  Pustchxy(max_i,max_j,DR);
 
  putch('\n');
 
  return 0;
}
 
void Pustchxy(int x, int y,int ch) {
  COORD pos;
 
  pos.X=(SHORT)x;
  pos.Y=(SHORT)y; 
  SetConsoleCursorPosition(ghOutput,pos);
  putch(ch);
}
cs


C/C++ 언어 원하는 위치에 사각형 그리기



+ Recent posts