Những câu hỏi liên quan
Nguyễn Ngọc Diễm My
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 4 2022 lúc 18:53

#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;

}

Bình luận (0)
MAI GIA BẢO 7A3
Xem chi tiết
Phía sau một cô gái
23 tháng 4 2023 lúc 20:25

n = int(input("Nhập số lượng phần tử: "))

lst = []

for i in range(n):

      lst.append(int(input("Nhập phần tử thứ {}:".format(i+1))))

lst.sort()

print("Danh sách đã sắp xếp theo thứ tự tăng dần:", lst)

Bình luận (0)
Huy Phạm
Xem chi tiết
Kiều Vũ Linh
3 tháng 5 2023 lúc 6:12

1)

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

i,n,t:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

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

End;

For i:=1 to n do

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

Begin

t:=a[i];

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

a[i+1]:=t;

End;

Write('Sap xep tang dan ');

For i:=1 to n do write(a[i]:8);

Readln

End.

Bình luận (0)
Kiều Vũ Linh
3 tháng 5 2023 lúc 6:13

2)

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

i,n,t:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

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

End;

For i:=1 to n do

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

Begin

t:=a[i];

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

a[i+1]:=t;

End;

Write('Sap xep giam dan ');

For i:=1 to n do write(a[i]:8);

Readln

End.

Bình luận (0)
Jhon wisk
Xem chi tiết
Kiều Vũ Linh
25 tháng 4 2023 lúc 7:31

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.

Bình luận (0)
༺ミ𝒮σɱєσиє...彡༻
Xem chi tiết
nuqueH
13 tháng 5 2022 lúc 21:41

tham khảo:

uses crt;

var n,i:integer;

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

begin

clrscr;

write(‘nhap so phan tu cua day:’);readln(n);

for i:=1 to n do

begin

write(‘a[‘,i,’]=’);readln(a[i]);

end;

writeln(‘day so da nhap:’);

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

readln;

end.

Bình luận (1)
Minh
13 tháng 5 2022 lúc 21:42

tham khảo

uses crt;

var n,i:integer;

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

begin

clrscr;

write(‘nhap so phan tu cua day:’);readln(n);

for i:=1 to n do

begin

write(‘a[‘,i,’]=’);readln(a[i]);

end;

writeln(‘day so da nhap:’);

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

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
13 tháng 5 2022 lúc 23:05

uses crt;

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

i,n,tam,j:integer;

begin

clrscr;

readln(n);

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

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;

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

readln;

end.

Bình luận (0)
khonopro
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 3 2023 lúc 15:01

#include <bits/stdc++.h>

using namespace std;

int A[1000],n,i;

int main()

{

cin>>n;

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

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

for (int i=1; i<=n; i++)

cout<<A[i]<<" ";

cout<<endl;

for (int i=2; i<=n; i++)

cout<<A[i]-A[i-1]<<endl;

return 0;

}

Bình luận (1)
Huyền Diệu Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 12 2021 lúc 0:49

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[1000];

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;

}

Bình luận (0)
Thắng Lee
Xem chi tiết
nguyễn an phát
Xem chi tiết