Program tohop;
Uses Crt;
Var n,k:integer;
Function gt(n:integer):longint;
Var kq,i:integer;
Begin
kq:=1;
For i:=1 to n do
kq:=kq*i;
gt:=kq;
End;
Function pt(n,k:integer):real;
Begin
pt:=gt(n)/(gt(k)*gt(n-k));
End;
Begin
Clrscr;
Writeln('CHUONG TRINH TINH TO HOP N CHAP K:');
Writeln('--------------------------------');
Write('Nhap n = '); readln(n);
Write('Nhap k = ');readln(k);
Writeln('C(',n,',',k,') = ',pt(n,k):6:0);
Readln;
End.
chinh hop
Program chinhhop;
uses crt;
var n:integer;x:longint;
var a : longint; b:longint;
var gt:integer;
Procedure Giai_Thua(var gt:longint; n:byte);
begin
gt:=1;
while n>0 do
begin
gt:=gt*n;
n:=n-1;
end;
end;
Function pt(a,b:integer):real;
Begin
pt:=gt(a)/(gt(a)*gt(a-b));
End;
begin
repeat
clrscr;
if n < 0 then begin write('Nhap so n>=0');readln; end;
until n>=0;
Giai_Thua(x,n);
writeln('nhap so a =') ;readln(a);
writeln('nhap so b =');readln(b);
Writeln('p(',a,',',b,') = ',pt(a,b):6:0);
readln
end.