Kiểu dữ liệu có cấu trúc

CG

1, Cho day B gom n phan tu thuc. Tim GTNN cua day?

2, Cho day gom n phan tu ≠ nhau. Hay sap xep day thanh day giam dan.

NT
18 tháng 2 2021 lúc 20:54

Câu 1: 

uses crt;

var b:array[1..100]of real;

i,n:integer;

min:real;

begin

clrscr;

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

for i:=1 to n do 

  begin

write('B[',i,']='); readln(b[i]);

end;

min:=b[1];

for i:=1 to n do 

  if min>b[i] then min:=b[i];

writeln('Gia tri nho nhat la: ',min:4:2);

readln;

end.

Câu 2:

uses crt;

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

i,n,j,tam:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

for i:=1 to n-1 do

  for j:=i+1 to n do 

if a[i]<a[j] then

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

end;

writeln('Day giam dan la: ');

for i:=1 to n do write(a[i]:4);

readln;

end.

Bình luận (0)

Các câu hỏi tương tự
CG
Xem chi tiết
H24
Xem chi tiết
DT
Xem chi tiết
LM
Xem chi tiết
KK
Xem chi tiết
PV
Xem chi tiết
LD
Xem chi tiết
0H
Xem chi tiết
UN
Xem chi tiết