K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

26 tháng 4 2019

var A:array[1..10000] of longint;

begin

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

for i:=1 to n do readln(A[i]);

max:=A[1]; min := A[1];

for i:=1 to n do

begin

if A[i]>max then max:=A[i];

if A[i]<min then min:=A[i];

end;

for i:=1 to n do

26 tháng 4 2019

for j:=i+1 to n do

if A[i]>A[j] then begin t:=A[i]; A[i]:=A[j]; A[j]:=t; end;

write(min,' ',max);

for i:=1 to n do writeln(A[i]);

readln

end.

{ Bo sung phan khai bao:

Them phan nay vao khai bao

i,j,n,max,min:longint;

}

24 tháng 4 2022

Đúng là anh thành sứt, lên đây hỏi ạ.

 

25 tháng 4 2023

Var a:array[1..1000] of integer;

i,m,tam:integer;

Begin

Write('m = ');readln(m);

For i:=1 to m do

Begin

Write('Nhap so thu ',i,' = ');readln(a[i]);

End;

For i:=1 to m do

If a[i] < a[i+1] then

Begin

tam:=a[i];

a[i]:=a[i+1];

a[i+1]:=tam;

End;

Write('Mang sau khi sap xep: ');

For i:=1 to m do

Write(a[i]:8);

Readln;

End.

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

sort(a+1,a+n+1);

for (i=n; i>=1; i--) cout<<a[i]<<" ";

return 0;

}

22 tháng 3 2023

program SapXepMang;
var
  N, i, j, temp: integer;
  arr: array of integer;
begin
  write('Nhap N: ');
  readln(N);
  SetLength(arr, N);
  for i := 0 to N - 1 do
  begin
    write('Nhap phan tu thu ', i + 1, ': ');
    readln(arr[i]);
  end;
  for i := 0 to N - 2 do
    for j := i + 1 to N - 1 do
      if arr[i] < arr[j] then
      begin
        temp := arr[i];
        arr[i] := arr[j];
        arr[j] := temp;
      end;
  writeln('Mang da sap xep theo thu tu giam dan: ');
  for i := 0 to N - 1 do
    write(arr[i], ' ');
  readln;
end.

 

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n;

int main()

{

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

sort(a+1,a+n+1);

for (i=n; i>=1; i--) cout<<a[i]<<" ";

return 0;

}

2 tháng 4 2023

program sapxep;

var

     i, j, n, x: integer;

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

begin

     write('Nhap so phan tu trong day: ');

     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

                    x := a[i];

                    a[i] := a[j];

                    a[j] := x;

               end;

     write('Nhap so x: ');

     readln(x);

     for i := 1 to n do

     begin

          if x <= a[i] then

          begin

               for j := n downto i + 1 do

                    a[j] := a[j-1];

               a[i] := x;

               break;

          end;

     end;

     writeln('Day so vua sap xep va them phan tu x:');

     for i := 1 to n do

          write(a[i], ' ');

     writeln;

end.