roc298
01-26-2004, 01:05 AM
Ok, this is probably a stupid question, with a simple answer. I'm just getting started learning VB.net, and at the moment I'm workin with arrays. The program I'm writing asks the user for 5 numbers, inputs them in an array, and then prints out the numbers to the screen, minus any duplicate numbers entered. I have the thing sorted and eliminating duplicates, but it's also eliminating the number that was duplicated. Any help with this is appreciated. This is what i have so far:
Console.WriteLine("Please enter 5 numbers between 0 and 100: ")
Console.WriteLine("")
For i = 0 To num.GetUpperBound(0)
num(i) = Console.ReadLine()
Next
For pass = 1 To num.GetUpperBound(0)
For i = 0 To num.GetUpperBound(0) - 1
If num(i) > num(i + 1) Then
swap(num, i)
End If
Next
Next
Console.WriteLine()
Console.WriteLine("Numbers entered(minus duplicates):")
Console.WriteLine()
For i = 0 To num.GetUpperBound(0) - 1
If num(i) <> num(i + 1) Then
num(i) = num(i)
Console.WriteLine(num(i))
End If
Next
Console.WriteLine("Please enter 5 numbers between 0 and 100: ")
Console.WriteLine("")
For i = 0 To num.GetUpperBound(0)
num(i) = Console.ReadLine()
Next
For pass = 1 To num.GetUpperBound(0)
For i = 0 To num.GetUpperBound(0) - 1
If num(i) > num(i + 1) Then
swap(num, i)
End If
Next
Next
Console.WriteLine()
Console.WriteLine("Numbers entered(minus duplicates):")
Console.WriteLine()
For i = 0 To num.GetUpperBound(0) - 1
If num(i) <> num(i + 1) Then
num(i) = num(i)
Console.WriteLine(num(i))
End If
Next