RosettaCodeData/Task/Vector/Chipmunk-Basic/vector.basic

38 lines
1.1 KiB
Plaintext

100 cls
110 dim vect1(2)
120 vect1(1) = 5 : vect1(2) = 7
130 dim vect2(2)
140 vect2(1) = 2 : vect2(2) = 3
150 dim vect3(ubound(vect1))
160 for n = 1 to ubound(vect1)
170 vect3(n) = vect1(n)+vect2(n)
180 next n
190 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] + ["+str$(vect2(1))+", "+str$(vect2(2))+"] = ";
200 showarray(vect3)
210 for n = 1 to ubound(vect1)
220 vect3(n) = vect1(n)-vect2(n)
230 next n
240 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] - ["+str$(vect2(1))+", "+str$(vect2(2))+"] = ";
250 showarray(vect3)
260 for n = 1 to ubound(vect1)
270 vect3(n) = vect1(n)*11
280 next n
290 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] * 11 = ";
300 showarray(vect3)
310 for n = 1 to ubound(vect1)
320 vect3(n) = vect1(n)/2
330 next n
340 print "["+str$(vect1(1))+", "+str$(vect1(2))+"] / 2 = ";
350 showarray(vect3)
360 end
370 sub showarray(vect3)
380 print "[";
390 svect$ = ""
400 for n = 1 to ubound(vect3)
410 svect$ = svect$+str$(vect3(n))+", "
420 next n
430 svect$ = left$(svect$,len(svect$)-2)
440 print svect$;
450 print "]"
460 end sub