I'm thinking of a number.
- if it is not a multiple of 4, then it is between 60 and 69
- if it is a multiple of 3 it is between 50 and 59
- if it is not a multiple of 6 it is between 70 and 79.
What is the number?
The number is 76
Program used:
Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
Sub Main()
Randomize()
Dim strstarttime As String
Dim strendtime As String
Dim strend As String
Dim strflag = "n"
strstarttime = TimeOfDay
Console.WriteLine("Start of execution: " & strstarttime)
For index1 As Integer = 50 To 79
findthenumber(index1)
Next
strendtime = TimeOfDay
Console.WriteLine(" ")
Console.WriteLine("Start of execution: " & strstarttime)
strendtime = TimeOfDay
Console.WriteLine("End of execution: " & strendtime)
strend = "?"
Console.WriteLine(" ")
While strend <> "X"
Console.WriteLine("Please enter X to exit program...")
strend = UCase(Console.ReadLine())
End While
End Sub
Sub findthenumber(ByRef index1)
Dim strcond(3) As String
For index2 As Integer = 0 To 2
strcond(index2) = "?"
Next
If (index1 Mod 4) <> 0 Then
If index1 >= 60 And _
index1 <= 69 Then
strcond(0) = "y"
Else
strcond(0) = "n"
End If
End If
If (index1 Mod 3) = 0 Then
If index1 >= 50 And _
index1 <= 59 Then
strcond(1) = "y"
Else
strcond(1) = "n"
End If
End If
If (index1 Mod 6) <> 0 Then
If index1 >= 70 And _
index1 <= 79 Then
strcond(2) = "y"
Else
strcond(2) = "n"
End If
End If
If strcond(0) <> "n" And strcond(1) <> "n" And _
strcond(2) <> "n" Then
Console.WriteLine( _
"Good: " & Str(index1))
End If
End Sub
End Module
|
Posted by Penny
on 2004-09-24 09:39:46 |