21. oa誰n ch旦担ng tr狸nh sau la淡m g狸:
7
Function GT(n:word;): word;
Var i,K: word;
Begin
K:=1;
For i:=1 to n do K:=K*i;
GT:=K;
End;
T鱈nh gia湛 tr嘆 cu短a nk
T鱈nh k*n
T鱈nh n!
T鱈nh k * n * (n-1)
29. Gia短 s旦短 ta co湛 ha淡m luythua 単e奪 t鱈nh an nh旦
sau:
11
Function luythua (a,n: integer): integer;
Var t,j: integer;
Begin
T :=1; for i:=1 to n do t:=t*a;
....................
Luythua:=t;
End;
ien ca但u le辰nh th鱈ch h担誰p va淡o.......
30. HOAT ONG NHOM (10)
1. Vie叩t ha淡m doixung(s:tring): boolean; 単e奪 kie奪m tra xa但u
s co湛 pha短i la淡 xa但u 単o叩i x旦湛ng hay kho但ng?
2. Vie叩t thu短 tu誰c thay toa淡n bo辰 t旦淡 bo但ng trong xa但u s
tha淡nh t旦淡 hoa
3. Vie叩t ch旦担ng tr狸nh ch鱈nh go誰i 2 ctcon tre但n th旦誰c hie辰n
31. Function doixung (s:string): boolean;
Var s1: string; i:byte;
Begin
s1:=;
for i:=length(s) downto 1 do s1:=s1+s[i];
If s1:=s then doixung:=true else doixung:=false;
End;
32. Procedure thaythe(var s:string);
Var i,t: byte;
Begin
While (pos(bong,s)>0) do
Begin
T:=pos(bong,s);
Delete(s,t,4);
Insert(hoa,s,t);
End;
End;
33. Program bt1;
Var s: string;
Function doixung(s:string):boolean;
Procedure thaythe (var s:string);
Begin (* chuong trinh chinh*)
Write(nhap xau s=); readln(s);
If doixung(s) then writeln(s, la xau DX);
Thaythe(s);
Writeln(xau da thay:,s);
Readln;
End.