Code: Select all
Max Size = 5
REDIM MyArray(Maxsize)
For I = 1 to Maxsize
MyArray (I) = INT(Rnd(1) *100) + 1
PRINT MyArray(I); SPACE$(1);
NEXT I
PRINT "(Initial Array)"
For Arraypos = 2 to Maxsize
Tempvalue = Myarray(Arraypos)
StopNow = 0
Count = 1
Time2Stop = 0
WHILE (TIme2Stop = 0)
If TempValue < MyArray(Count) THEN
For J = ArrayPos to Count Step -1
Myarray(J) = Myarray(J - 1)
NEXT j
Myarray(count) = TempValue
StopNow = 1
FOR I = 1 to MaxSize
PRINT Myarray(I); SPACE$;
Next I
PRINT
END IF
Count = Count +1
If (StopNow = 1) OR (Count = ArrayPos) THEN
Time2stop = 1
End if
WEND
NEXT ArrayPos
For I =1 To MaxSize
Print MyArray(I) SPACE$;
Next I
PRINT "(Sorted Array)"
1: Why did they make Maxsize equal to 6 if the only used 5? And how did they use the Redim function if Myarray hasn't been declaired yet?
2:What does INT (RND (1) *100) +1 do? It never explained it.
3:ArrayPos to Count step -1 would repeat twice, wouldn't it? If so, why would it need to?
4:How did they use the PRINT function with nothing to print?
These are my questions for now.