一题多解的奇怪算法,不太明白
现有四个文本框,一个按钮,在其中三个输入数字后,按按钮,会在第四个文本框中显示最大的数字,有两种方法:
1.
private sub cmdmax_click
dim int1 as integer,int2 as integer,int3 as integer
int1=cint(text1.text):int2=cint(text2.text):int3=cint(text3.text)
if int1>int2 then
if int1>int3 then
textmax.text=int1
else
textmax.text=int3
end if
else
if int3>int2 then
textmax.text=int3
else
textmax.text=int2
end if
end if
end sub
这一种我明白,可是第二种就不明白了,请各位为我讲讲,谢谢
2.
private sub cmdmax_click
dim int1 as integer,int2 as integer,int3 as integer,intmax as _ integer
int1=cint(text1.text):int2=cint(text2.text):int3=cint(text3.text)
intmax=int1
if intmax<int2 then
intmax=int2
end if
if intmax<int3 then
intmax=int3
end if
textmax.text=intmax
end sub
如果这样的话,如果intmax同时小于int2和int3,那么textmax.text该显示什么?int2 or int3?