在某一黑夜一司机碰伤行人之后落荒而逃,经过三个目击者;甲说;车牌号的前两为相同;乙说;车牌号的后两位加起来等于6;丙说;车牌号是一个四位数并且能被2整除。根据上述提供的线索,编写程序找出肇事车可能车牌号。 排查条件:设车牌号为x 四位数分别为a b c d条件可写为:“a=b And c+d=6 And x Mod 2=0”我要的事运行程序。
dim i as integer,b as string,a as string
a=""
for i=0 to 9999 step 2 b=trim(str(i)) while len(b)<4 b="0" & b wend if mid(b,1,1)=mid(b,2,1) and val(mid(b,3,1))+val(mid(b,4,1))=6 then a=a & b & ","
next
print a
Dim i As Integer, b As String
List1.Clear
For i = 0 To 9999 Step 2 b = Trim(Str(i)) While Len(b) < 4 b = "0" & b Wend If Mid(b, 1, 1) = Mid(b, 2, 1) And Val(Mid(b, 3, 1)) + Val(Mid(b, 4, 1)) = 6 Then If Val(Mid(b, 1, 1)) Mod 2 = 0 And Val(Mid(b, 2, 1)) Mod 2 = 0 Then List1.AddItem b End If End If
Next i