páscal
program Giai_PTB2;
uses crt;
var a,b,c:real;
D,x1,x2:real;
begin
clrscr;
while(a=0)do
begin
write('a = ');
readln(a);
end;
write('b = ');
readln(b);
write('c = ');
readln(c);
D:=b*b-4*a*c;
if D<0 then
writeln('Phuong trinh vo nghiem.')
else
begin
x1:=(-b-sqrt(D))/(2*a);
x2:=-b/a-x1;
writeln('x1= ',x1:8:3,' x2= ',x2:8:3);
end;
readln
end.
program Nam_nhuan;
uses crt;
var N,SN:integer;
begin
clrscr;
write('Nam: ');
readln(N);
if(N mod 400=0)or((N mod 4=0)and(N mod 100<>0))then
SN:=366
else
SN:=365;
writeln('So ngay cua nam ',N,' la ',SN);
readln
end.
program UCLN;
uses crt;
var M,N:integer;
begin
clrscr;
write('M,N= ');
readln(M,N);
while M<>N do
if M>N then M:=M-N else N:=N-M;
writeln('UCLN= ',M);
readln
end.
program Tong_ngich_dao;
uses crt;
var S:real;
a,N:integer;
begin
clrscr;
write('Hay nhap gia tri a: ');
readln(a);
S:=1.0/a;
N:=0;
while not(1/(a+N)<0.0001) do
begin
N:=N+1;
S:=S+1.0/(a+N);
end;
writeln('Tong S la :',S:8:4);
readln
end.
program Pi_ta_go;
uses crt;
var a,b,c:integer;
a2,b2,c2:longint;
begin
clrscr;
write('a,b,c:');
readln(a,b,c);
a2:=a;
b2:=b;
c2:=c;
a2:=a2*a;
b2:=b2*b;
c2:=c2*c;
if(a2=b2+c2)or(b2=a2+c2)or(c2=a2+b2)then
writeln('Ba so da nhap la bo so Pi-ta-go')
else
writeln('Ba so da nhap khong la bo so Pi-ta-go');
readln
end.
program GaCho;
uses crt;
var ga,cho:integer;
begin
clrscr;
ga:=1;
cho:=36-ga;
while ga*2+cho*4<>100 do
begin
ga:=ga+1;
cho:=36-ga;
end;
writeln('Ga : ',ga:3);
write('Cho: ',cho:3);
readln
end.
program Tuoi;
uses crt;
var tcha,tcon,dem:integer;
begin
clrscr;
while not((tcha>tcon*2)and(tcha-tcon>=25)) do
begin
write('Nhap tuoi cha, tuoi con : ');
readln(tcha,tcon);
end;
dem:=0;
while not(tcha=tcon*2) do
begin
tcha:=tcha+1;
tcon:=tcon+1;
dem:=dem+1;
end;
write('Tuoi cha gap doi tuoi con sau ',dem,' nam');
readln
end.
program Lai;
uses crt;
var A,B:real;
dem:integer;
begin
clrscr;
write('Nhap so tien A: ');
readln(A);
write('Nhap so tien tong cong B: ');
readln(B);
dem:=0;
while B>A+dem*A*0.003 do
begin
dem:=dem+1;
end;
write('Ban nhan duoc ',B:8:3,' sau ',dem,' thang');
readln
end.
Bạn đang đọc truyện trên: AzTruyen.Top