[英]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.