Lập trình đơn giản

H24

1.Viết chương trình tìm GTLN của dãy số nguyên

2.Nhập chiều cao cho 3 bạn và đưa ra bạn có chiều cao lớn nhất

NT
1 tháng 4 2021 lúc 22:39

1: 

uses crt;

var a:array[1..100]of integer;

i,n,max:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

 begin

write('A[',i,']='); readln(a[i]);

end;

max:=a[1];

for i:=1 to n do 

  if max<a[i] then max:=a[i];

writeln(max);

readln;

end.

Bình luận (0)
H24
1 tháng 4 2021 lúc 21:21

program oken;

uses crt;
var a: array [1..100] of integer;
    i,n,max:integer;
begin
        clrscr;
        write('nhap so n: '); readln(n);
        for i:=1 to n do
                begin
                        write('a[',i,']: ');
                        readln(a[i]);
                end;

b,

program aicaohon;

uses crt;

var Nhi, Tram,An:real;

begin

clrscr;

write('nhap chieu cao cua Nhi=');readln(Nhi);

write('nhap chieu cao cua Tram='); readln(Tram);

if Nhi>Tram then writeln('Ban Nhi cao hon');

if Tram>Nhi then writeln('Ban Tram cao hon')

if An>Tram>Nhi then writeln( 'Ban An cao nhat')

else writeln('An cao nhat');

readln

end.

        max:=a[1];
        for i:=2 to n do
                if a[i]>max then
                        max:=a[i];
        writeln('Max: ',max);
        readln;
end.

Bình luận (1)
NT
1 tháng 4 2021 lúc 22:41

2:

uses crt;

var a:array[1..3]of real;

i:integer;

max:real;

begin

clrscr;

for i:=1 to 3 do

 begin

write('Nhap chieu cao cua ban thu ',i,':'); readln(a[i]);

end;

max:=a[1];

for i:=1 to 3 do 

  if max<a[i] then max:=a[i];

writeln(max);

readln;

end.

Bình luận (0)

Các câu hỏi tương tự
BH
Xem chi tiết
ND
Xem chi tiết
NL
Xem chi tiết
YP
Xem chi tiết
T8
Xem chi tiết
LV
Xem chi tiết
H24
Xem chi tiết
H24
Xem chi tiết
H24
Xem chi tiết