1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define WIDTH 39
#define HEIGHT 24
char buff[WIDTH*HEIGHT*4];
void draw_line(x1,y1,x2,y2) {
buff[(y1*WIDTH*2)+x1]='+';
buff[(((y1+y2)/2) * WIDTH *2)+((x1+x2)/2)]=
(x1==x2)?'|':(y1==y2)?'-':((x1<x2&&y1>y2)||(x1>x2&&y1<y2))?'/':'\\';
buff[(y2*WIDTH*2)+x2]='+';
}
int main(int argc,char *argv[]) {
int x1,y1,x2,y2,y;
memset(buff,' ',WIDTH*HEIGHT*4);
while(scanf("%d %d %d %d",&x1,&y1,&x2,&y2) == 4)
draw_line((x1+8)*2,(y1+8)*2,(x2+8)*2,(y2+8)*2);
for(y=0;y<HEIGHT*2;y++,write(1,"\n",1)) write(1,buff+(y*WIDTH*2),WIDTH*2);
return 0;
}
|