我想把这段代码翻译成VB.NET版,但我不知道怎么做。
Pyhton代码:
import math
skippie=raw_input("If you know how to do this, enter skip ")
if skippie=="skip":
found = False
varmin=1
varmax=100
while not found:
guess = (varmax+varmin)/2
ans=raw_input("Is your input larger (l), smaller(s), or equal to (e) than " + str(guess) + " ")
if ans == "L" or ans == "l":
varmin = guess
elif ans == "S" or ans == "s":
varmax = guess
else:
print "Yay! I got it!"
found = True
粘贴箱代码:pastebin link
我认为这段代码可以改进,但我认为将其与原始代码保持非常接近会更有帮助:
下一次,请尝试在发布前自己翻译代码,并用结果发布您的尝试。你知道吗
编辑:Windows窗体版本
我也对这个版本做了一些风格上的修改。(我基本上消除了不必要的变量)行为是相同的,但在我看来,第二个版本更vb.net,而第一个版本更python。你知道吗
相关问题 更多 >
编程相关推荐