Được gửi bởi
vumanh.cuong
Viết ct nhập vào dãy số nguyên có n phần tử
a) sắp xếp theo thứ tự tăng dần.
b) Nhập vào số bất kỳ, đếm số lần xuất hiện của nó trên dãy.
c) in ra màn hình số nhỉ hơn hoặc bằng số vừa nhập.
d) in ra màn hình số lớn hơn số vừa nhập..
anh chị nào biết giúp em vs nha
Code:
PROGRAM BT;
VAR
A: Array [1..100] of integer;
n,i,i,tg,x,t: integer;
BEGIN
Write('Nhap so phan tu: ');
Readln(n);
For i:=1 to n do
Begin
Write('A[',i,']= ');
Readln(A[i]);
end;
Writeln('Day vua nhap:');
For i:=1 to n do
Write(A[i]:5);
Writeln;
For i:=1 to n-1 do
For j:=i+1 to n do
if a[j]<a[i] then
begin
tg:=a[i];a[i]:=a[j];a[j]:=tg;
end;
Writeln('Day sau khi sap xep:');
For i:=1 to n do
Write(A[i]:5);
Writeln;
t:=o
For i:=1 to n do
if A[i]=x then
t:=t+1;
Writeln('So lan xuat hien cua ',x,' trong day la: ',t) ;
Write('Nhap vao so nguyen bat ky: ');
Readln(x);
Write('Cac so <= ',x);
For i:=1 to n do
if A[i]<= x then
Write(A[i]:5);
Writeln;
Write('Cac so >= ',x);
For i:=1 to n do
if A[i]>= x then
Write(A[i]:5);
Writeln;
Readln;
END.
Bookmarks