✔ 最佳答案
我都係F.4架~
1)I would like to ask how can we use string in free pascal?
係 var 度 ,例如
var password:string;
2) how can we use procedure?
係main program 前面(姐係begin前面)打
例 輸出兩個數中最大值的過程
procedurelargest(a,b:integer);
begin
if a>b then writeln(a)
else writeln(b);
end;
然後係main program 度要用果時就call番佢出呢
program main;
var a,b:integer;
procedure largest(a,b:integer);
begin
if a>b then wirtlen(a)
else writlen(b);
end;
begin
readln(a,b);
largest(a,b);
end.
3)how can we use for loop, repeat loop and while loop in a program using strings?
幾時都用得 for loop,repeat loop and while loop,上次答你果條係例子
4) how can we use boolean?
同string差唔多,係var度打
var flag:boolean
5)how can we use val,pos,copy,length and function in a program using string?
當你有一個string,例如咁
program main;
var password:string;
num,error,length:integer;
begin
password:=abcba;
val(password,num,error);
pos(c,password);
copy(password,1,1);
length:=length(password);
end.
val就係將一個string轉做數字,如果得,num就會係個堆數字,如果唔得,error就係由第幾個轉唔到數字既數,依家因為係eng words所以num係0,error係1
如果個string 係 12AB ,num係0,error係3
pos就係係一個string入面搵你要搵既字,佢會出番個字既位置,依家就係3
copy就係將一個string入面第幾個字拎幾多個出呢,依家就係abcba入面拎由第1個開始計1個,姐係a
length最易,就係個string既長度,依家就係5
2011-12-31 20:15:39 補充:
你試下寫個program,叫人地入一個password
如果個password 有8個字OR以上,有數字同英文字,咁就叫GOOD
否則就要寫出佢差邊樣,咁叫佢入,直到GOOD為止
Enter a password:123Test
The password should contain at least 8 characters.
Bad password.
Enter a password:QQ
The password should contain at least 8 characters.
Missing digit.
Bad password.
2011-12-31 20:15:48 補充:
Enter a password:!@#$%
The password should contain at least 8 characters.
Missing digit.
Missing letter.
Bad password.
Enter a password:1234TestTest
The password is strong.