for counter := 1 to lengthofpassword do
begin
currentletter:=password[counter];
currentascii:=Ord(currentletter);
if (96<currentascii<123) OR (64<currentascii<91) OR (47<currentascii<58) then
Writeln('valid')
else
asciicheck:=false;
end;
我知道這段代碼是錯誤的,但我做了解釋我想問什麼。如何指定if語句的範圍?之前,我搞砸了很多if語句,並且我的代碼沒有按照我想要的方式工作。基本上,我正在制定一個程序,檢查用戶輸入的大小寫字母和數字以外的任何內容。這個問題是不同的,因爲我正在尋找如何使用Case Of語句解決這個問題。如何在Delphi中爲if語句指定多個範圍?
for counter := 1 to lengthofpassword do
begin
currentletter:=password[counter];
currentascii:=Ord(currentletter);
if (currentascii<48) AND (currentascii>57) then
asciipoints:=asciipoints+1;
if (currentascii<65) AND (currentascii>90) then
asciipoints:=asciipoints+1;
if (currentascii<97) AND (currentascii>122) then
asciipoints:=asciipoints+1;
Writeln(asciipoints);
end;
我也試着像這樣做,但後來意識到這是行不通的,因爲如果一個聲明是滿意的,其他人也不會和計點積分制將不能工作。
什麼是你的,當然目前的話題?你有什麼需求來解決這個任務嗎?否則,您可能需要查看一組char。 – nil
乾杯,我結束了使用像97..122爲字母表 –