-
Notifications
You must be signed in to change notification settings - Fork 0
/
addorder.bas
171 lines (171 loc) · 3.13 KB
/
addorder.bas
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "string.bi"
const xd=300
const yd=200
const esc=27
const data_size=7
type group
group_ (0 to 1000) as double
count as integer=0
end type
sub fill_group(g1 as group)
dim n as integer
g1.count=data_size
for n=0 to data_size-1
read g1.group_(n)
next
end sub
sub add_(g1 as group,i as double)
if g1.count<999 then
g1.group_(g1.count)=i
g1.count=g1.count+1
end if
end sub
sub printGroup(g1 as group)
dim n as integer
for n=0 to g1.count-1
print format(g1.group_(n),"0.00");
if n<> g1.count-1 then print " , ";
next
print
end sub
function max(g1 as group) as double
dim n as integer
dim m as double=0
if g1.count > 0 then
m=g1.group_(0)
for n=0 to g1.count-1
if g1.group_(n)>m then m=g1.group_(n)
next
end if
return m
end function
function min(g1 as group) as double
dim n as integer
dim m as double=0
if g1.count > 0 then
m=g1.group_(0)
for n=0 to g1.count-1
if g1.group_(n)<m then m=g1.group_(n)
next
end if
return m
end function
function med(g1 as group) as double
dim n as integer
dim m as double=0
dim r as double=0
if g1.count > 0 then
m=0
for n=0 to g1.count-1
m=m+g1.group_(n)
next
if m<>0 then r=m/g1.count
end if
return r
end function
function sum(g1 as group) as double
dim n as integer
dim m as double=0
dim r as double=0
if g1.count > 0 then
m=0
for n=0 to g1.count-1
m=m+g1.group_(n)
next
end if
return m
end function
sub display(xx as group,yy as group)
dim k as string
dim n as integer
screenres xd,yd,8
line (0,0)-(xd,yd),0,bf
line (0,yd/2)-(xd,yd/2),7
line (xd/2,0)-(xd/2,yd),7
if xx.count<> yy.count or xx.count < 1 then
goto escapes
end if
for n=0 to xx.count-1
circle ((xd/2)+xx.group_(n)*5,(yd/2)+yy.group_(n)*5),3,7,,,,f
next
while true
k=inkey()
if k=chr(esc)then goto escapes
wend
escapes:
end sub
sub savedatas(g1 as group,names as string)
dim n as integer
open names for output as #1
for n=0 to g1.count-1
print #1,trim(str(g1.group_(n)))
next
close #1
end sub
sub loaddatas(g1 as group,names as string)
dim n as integer
dim d as double
dim s as string
open names for input as #1
while not eof(1)
line input #1,s
d=val(s)
add_ g1,d
wend
close #1
end sub
function percent(value as double,per as double)as double
dim d as double
d=value/100*per
return d
end function
sub reverse(g1 as group)
dim n as integer
dim g2 as group
for n=0 to g1.count-1
g2.group_(n)=g1.group_(n)
next
g2.count=g1.count
for n=g1.count-1 to 0 step -1
g1.group_(g1.count-1-n)=g2.group_(n)
next
end sub
sub addsort(g1 as group,i as double)
dim n as integer
dim d as double
dim dd as double
d=i
if g1.count<999 then
if g1.count>0 then
for n=0 to g1.count-1
if g1.group_(n)>d then
dd=g1.group_(n)
g1.group_(n)=d
d=dd
end if
next
g1.group_(g1.count)=d
g1.count=g1.count+1
else
g1.group_(g1.count)=d
g1.count=g1.count+1
end if
end if
end sub
sub fillread(g1 as group)
dim n as integer
dim d as double
for n=0 to data_size-1
read d
addsort g1,d
next
end sub
data 12,7,5,3,9,10,8
data 12,7,5,3,9,10,8
dim g1 as group
fillread g1
print "group:"
printGroup g1
reverse g1
print "group:"
printGroup g1