[英]Making numbers and letters valid and invalid in turing
到目前為止,當您輸入字母時,我的數字是有效的,但是我不知道如何使數字有效。 我可以幫助您使數字和字母同時有效嗎?
var var_name : string
function check_letter (ch : string (1)) : int
if ord (ch) >= 65 and ord (ch) <= 90 then
result 1
end if
if ord (ch) >= 97 and ord (ch) <= 122 then
result 1
end if
if ord (ch) >= 0 and ord (ch) <= 9 then
result 1
end if
result 0
end check_letter
put "please enter the postal code"
get var_name
for i : 1 .. length (var_name)
if check_letter (var_name (i)) = 1 then
put "postal code valid"
else
put "postal code invalid"
end if
end for
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.