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

Charlotte Grace

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.

Nguyễn Lê Phước Thịnh
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.


Các câu hỏi tương tự
Charlotte Grace
Xem chi tiết
....
Xem chi tiết
Duong hanh trang
Xem chi tiết
Lan Trương (Lan Mèo)
Xem chi tiết
Khánh Khánh
Xem chi tiết
pham thuy vy
Xem chi tiết
Lê Tiến Đạt
Xem chi tiết
09 Lê Quang HIếu
Xem chi tiết
Uhuh now
Xem chi tiết