Những câu hỏi liên quan
Thắng Lee
Xem chi tiết
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.

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.

Diễn Mai
Xem chi tiết
HT.Phong (9A5)
6 tháng 4 2023 lúc 18:33

Uses crt;

Var k: array[1..10] of integer;

i,j,n: byte;

t: integer;

begin clrscr;

Readln(n);

For i:=1 to n do Begin

readln(k[i]);

end;

For i:=1 to n-1 do For j:=i+1 to n do

if k[j] <=k[i] then begin

t:= k[i];

k[i]:=M[j];

k[j]:=t; end;

For i:=1 to n do Write(k[i],''); readln;

end.

hoho209
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 3 2021 lúc 23:30

Bài 1: 

uses crt;

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

i,n,tam,j: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;

for i:=1 to n do 

  write(a[i]:4);

readln;

end.

hoho209
19 tháng 3 2021 lúc 0:35

Làm giúp em câu 2 với ạ

Huyền Trang
Xem chi tiết
Panda
Xem chi tiết
nam bảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 3 2022 lúc 14:01

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,t;

int main()

{

cin>>n;

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

t=0;

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

if (i%2!=0) t+=a[i]*a[i];

cout<<t<<endl;

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

if (a[i]<0) cout<<a[i]<<" ";

cout<<endl;

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

for (i=n; i>=1; i--)

cout<<a[i]<<" ";

return 0;

}

Trầm tiến
Xem chi tiết
Kiều Vũ Linh
16 tháng 5 2023 lúc 21:31

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

i,n,t,d:integer;

Begin

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

For i:=1 to n do

Begin

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

if (a[i] mod 2 = 0) and (a[i] mod 3 = 0) then

d:=d+1;

End;

Writeln('Co ',d,' so chia het cho 2 va 3');

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('Day sau khi sap xep la: ');

for i:=1 to n do

Write(a[i]:8);

Readln

End.

Phạm Thị Thanh
Xem chi tiết
thanh
27 tháng 10 2018 lúc 16:39
program sap_xep; var a,b,c,t:integer; Begin write(' nhap a ' ); readln(a); write(' nhap b ' ); readln(b); write(' nhap c ' ); readln(c); if a>b then begin t:=a; a:=b; b:=t; end; if b>c then begin t:=b; b:=c; c:=t; end; if a>b then begin t:=a; a:=b; b:=t; end; writeln(' day duoc sap xep'); writeln(a:5,b:5,c:5); readln End.