Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Smallest to Biggest
- '==============
- TextWindow.Title= "Biggest & Smallest Outta a set of Numbers
- ESC= Text.GetCharacter(27) ' ASCII code for "Esc" key
- LF= Text.GetCharacter(10) ' Jumps 1 line (Line Feed)
- 'Section 1
- 'Receives input for a set of numbers:
- Start:
- TextWindow.Clear()
- TextWindow.ForegroundColor= "Red
- TextWindow.Write("How many numbers to you want to order?: ")
- set = TextWindow.Read()
- TextWindow.WriteLine ("Type in numbers confirming each one with 'ENTER' key:" + LF)
- TextWindow.ForegroundColor= "Blue
- For index= 1 To set
- TextWindow.Write ("Number " + index + ": ")
- number[index] = TextWindow.ReadNumber() * 1
- EndFor
- 'Section 2
- 'Displays the 3 [SET of - DM Ed.] typed numbers:
- TextWindow.ForegroundColor= "DarkRed
- TextWindow.WriteLine (LF + "These are the numbers entered:")
- TextWindow.ForegroundColor= "DarkYellow
- For index= 1 To set
- TextWindow.WriteLine ( index + "-> " + number[index] )
- EndFor
- 'Section 3
- 'Calculates the average outta the numbers:
- sum = 0
- For i = 1 To set
- sum = sum + number [i]
- EndFor
- average= sum / set
- TextWindow.ForegroundColor= "Yellow
- TextWindow.WriteLine (LF + "Average for the numbers-> " + average + LF)
- 'Section 4
- 'Algorithm to bubble-sort out from smallest to biggest outta typed numbers:
- For times= 1 To set-1
- For index= 1 To set-1
- If number[index] > number[index+1] Then
- aux= number[index]
- number[index]= number[index+1]
- number[index+1]= aux
- EndIf
- EndFor
- EndFor
- 'Section 5
- 'Displays the comparison result:
- TextWindow.ForegroundColor= "Green
- TextWindow.WriteLine ("The ordered numbers from smallest to biggest:")
- TextWindow.ForegroundColor= "Cyan
- For index= 1 To set
- TextWindow.Write ( number[index] + ", " )
- EndFor
- 'Section 6
- 'Decides whether to end or restart the program depending on the key pressed:
- TextWindow.ForegroundColor= "Magenta
- TextWindow.WriteLine (LF + LF + "Press 'Q' or 'Esc' to quit or any other to restart...")
- key= Text.ConvertToUpperCase ( TextWindow.ReadKey() )
- If key = "Q" Or key = ESC Then
- Program.End()
- Else
- Goto start
- EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement