-
Notifications
You must be signed in to change notification settings - Fork 16
/
7.c
50 lines (50 loc) · 1.09 KB
/
7.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
#include<stdio.h>
#include <math.h>
int main()
{
int i;
float a, x, y1, y2;
a = 0.4;
printf(" y --------> \n");
printf("-------------------------------------\n");
for (x=0; x<5; x= x + 0.25)
{
y1 = (int) (50*exp(-a * x)+0.5);
y2 = (int) (50*exp(-a * x + x/2)+0.5);
if (y1 == y2)
{
if (x==2.5)
printf(" X |");
else
printf("|");
for (i=1; i <= y1-1; ++i)
printf(" ");
printf("#\n");
continue;
}
if (y1>y2)
{
if ( x == 2.5 )
printf(" X |");
else
printf(" |");
for (i=1; i <= y2-1; ++i )
printf(" ");
printf("*");
for ( i = 1; i <= (y1 - y2-1);++i)
printf("-");
continue;
}
if (x==2.5)
printf(" X |");
else
printf(" |");
for (i = 1; i <= (y1 - 1); ++i)
printf(" ");
printf("0");
for (i = 1; i <= (y2-y1-1); ++i)
printf("-");
printf("*\n");
}
printf(" |n");
}