0 bình luận về “Viết chương trình con tính m=(a!+b!)/3”
program phuongt; uses crt; var a, b: integer; m: real; function kt: real; var x, y, i: integer; begin x:=1; y:=1; for i:=1 to a do x:=x*i; for i:=1 to b do y:=y*i; m:=(x+y)/3; write(‘m = ‘, m:3:2); end; begin clrscr; write(‘Nhap a = ‘); readln(a); write(‘Nhap b = ‘); readln(b); kt; readln end.
uses crt; var a,b:longint; m:extended; {—Ham-giai-thua—} function gt:extended; var c,d,i:longint; begin c:=1;d:=1; for i:=1 to a do c:=c*i; for i:=1 to b do d:=d*i; m:=(c+d)/3; write(‘(‘,a,’!+’,b,’!)/3=’,m:0:2); end; {—Chuong-trinh-chinh—} BEGIN clrscr; write(‘Nhap a,b: ‘); readln(a,b); gt; readln; END.
program phuongt;
uses crt;
var a, b: integer;
m: real;
function kt: real;
var x, y, i: integer;
begin
x:=1; y:=1;
for i:=1 to a do x:=x*i;
for i:=1 to b do y:=y*i;
m:=(x+y)/3;
write(‘m = ‘, m:3:2);
end;
begin
clrscr;
write(‘Nhap a = ‘); readln(a);
write(‘Nhap b = ‘); readln(b);
kt;
readln
end.
uses crt;
var a,b:longint;
m:extended;
{—Ham-giai-thua—}
function gt:extended;
var c,d,i:longint;
begin
c:=1;d:=1;
for i:=1 to a do c:=c*i;
for i:=1 to b do d:=d*i;
m:=(c+d)/3;
write(‘(‘,a,’!+’,b,’!)/3=’,m:0:2);
end;
{—Chuong-trinh-chinh—}
BEGIN
clrscr;
write(‘Nhap a,b: ‘); readln(a,b);
gt;
readln;
END.