viết CT nhập vào cân nặng của 4 bạn, sau đó in ra màn hình tên và cân nặng của bạn nặng nhất và bạn nhẹ nhất
0 bình luận về “viết CT nhập vào cân nặng của 4 bạn, sau đó in ra màn hình tên và cân nặng của bạn nặng nhất và bạn nhẹ nhất”
program oken; uses crt; var c1,c2,c3,c4,max,min: real; s1,s2,s3,s4,ten1,ten2: string; begin clrscr; write(‘Nhap ten ban thu 1: ‘); readln(s1); write(‘Nhap chieu cao: ‘); readln(c1); write(‘Nhap ten ban thu 2: ‘); readln(s2); write(‘Nhap chieu cao: ‘); readln(c2); write(‘Nhap ten ban thu 3: ‘); readln(s3); write(‘Nhap chieu cao: ‘); readln(c3); write(‘Nhap ten ban thu 4: ‘); readln(s4); write(‘Nhap chieu cao: ‘); readln(c4); if (c1>c2) and (c1>c3) and (c1>c4) then begin max:=c1; ten1:=s1; end else if (c2>c1) and (c2>c3) and (c3>c4) then begin max:=c2; ten1:=s2; end else if (c3>c1) and (c3>c2) and (c3>c4) then begin max:=c3; ten1:=s3; end else begin max:=c4; ten1:=s4; end;
if (c1<c2) and (c1<c3) and (c1<c4) then begin min:=c1; ten2:=s1; end else if (c2<c1) and (c2<c3) and (c3<c4) then begin min:=c2; ten2:=s2; end else if (c3<c1) and (c3<c2) and (c3<c4) then begin min:=c3; ten2:=s3; end else begin min:=c4; ten2:=s4; end; writeln(‘Ten ban cao nhat: ‘,ten1,'(‘,max:0:2,’ m)’); writeln(‘Ten ban thap nhat: ‘,ten2,'(‘,min:0:2,’ m)’); readln; end.
program oken;
uses crt;
var c1,c2,c3,c4,max,min: real;
s1,s2,s3,s4,ten1,ten2: string;
begin
clrscr;
write(‘Nhap ten ban thu 1: ‘); readln(s1);
write(‘Nhap chieu cao: ‘); readln(c1);
write(‘Nhap ten ban thu 2: ‘); readln(s2);
write(‘Nhap chieu cao: ‘); readln(c2);
write(‘Nhap ten ban thu 3: ‘); readln(s3);
write(‘Nhap chieu cao: ‘); readln(c3);
write(‘Nhap ten ban thu 4: ‘); readln(s4);
write(‘Nhap chieu cao: ‘); readln(c4);
if (c1>c2) and (c1>c3) and (c1>c4) then
begin
max:=c1;
ten1:=s1;
end
else if (c2>c1) and (c2>c3) and (c3>c4) then
begin
max:=c2;
ten1:=s2;
end
else if (c3>c1) and (c3>c2) and (c3>c4) then
begin
max:=c3;
ten1:=s3;
end
else
begin
max:=c4;
ten1:=s4;
end;
if (c1<c2) and (c1<c3) and (c1<c4) then
begin
min:=c1;
ten2:=s1;
end
else if (c2<c1) and (c2<c3) and (c3<c4) then
begin
min:=c2;
ten2:=s2;
end
else if (c3<c1) and (c3<c2) and (c3<c4) then
begin
min:=c3;
ten2:=s3;
end
else
begin
min:=c4;
ten2:=s4;
end;
writeln(‘Ten ban cao nhat: ‘,ten1,'(‘,max:0:2,’ m)’);
writeln(‘Ten ban thap nhat: ‘,ten2,'(‘,min:0:2,’ m)’);
readln;
end.
program ct_pt;
uses crt;
var b1, b2, b3, b4: string;
a, b, c, d: real;
begin
clrscr;
write(‘Nhap ten ban dau tien: ‘); readln(b1);
write(‘Nhap can nang ban dau tien: ‘); readln(a);
write(‘Nhap ten thu 2: ‘); readln(b2);
write(‘Nhap can nang ban thu 2: ‘); readln(b);
write(‘Nhap ten ban thu 3: ‘); readln(b3);
write(‘Nhap can nang ban thu 3: ‘); readln(c);
write(‘Nhap ten ban thu 4: ‘); readln(b4);
write(‘Nhap can nang ban thu 4: ‘); readln(d);
if (a>b) and (a>c) and (a>d) then write(‘Ban ‘, b1, ‘ co can nang la ‘, a:1:1, ‘ nang nhat’);
if (b>a) and (b>c) and (b>d) then write(‘Ban ‘, b2, ‘ co can nang la ‘, b:1:1, ‘ nang nhat’);
if (c>a) and (c>b) and (c>d) then write(‘Ban ‘, b3, ‘ co can nang la ‘, c:1:1, ‘ nang nhat’);
if (d>a) and (d>b) and (d>c) then write(‘Ban ‘, b4, ‘ co can nang la ‘, d:1:1, ‘ nang nhat’);
if (a<b) and (a<c) and (a<d) then write(‘Ban ‘, b1, ‘ co can nang la ‘, a:1:1, ‘ nhe nhat’);
if (b<a) and (b<c) and (b<d) then write(‘Ban ‘, b2, ‘ co can nang la ‘, b:1:1, ‘ nhe nhat’);
if (c<a) and (c<b) and (c<d) then write(‘Ban ‘, b3, ‘ co can nang la ‘, c:1:1, ‘ nhe nhat’);
if (d<a) and (d<b) and (d<c) then write(‘Ban ‘, b4, ‘ co can nang la ‘, d:1:1, ‘ nhe nhat’);
readln
end.