-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAMI.C
More file actions
49 lines (36 loc) · 820 Bytes
/
AMI.C
File metadata and controls
49 lines (36 loc) · 820 Bytes
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
#include <graphics.h>
void main(){
int i, n, bits[10];
int gdriver = DETECT, gmode;
int xmax, ymax;
int last = -1;
initgraph(&gdriver, &gmode, "C:\\TURBOC3\\BGI");
setcolor(getmaxcolor());
xmax = getmaxx();
ymax = getmaxy();
line(0, ymax/2, xmax, ymax/2);
line(0, 0, 0, ymax);
printf("Enter size: ");
scanf("%d", &n);
setlinestyle(DASHED_LINE, 1, 1);
for(i = 0; i <=n; i++)
line(i * 50, 0, i * 50, ymax);
printf("Enter the digital code: ");
for(i = 0; i<n; i++)
scanf("%d", &bits[i]);
lineto(0, ymax/2);
setcolor(10);
setlinestyle(SOLID_LINE, 1, 1);
for(i = 0; i<n; i++){
if(bits[i]==1){
linerel(0, 50*last);
linerel(50, 0);
linerel(0, -50*last);
last *= -1;
}else{
linerel(50, 0);
}
}
getch();
closegraph();
}