Những câu hỏi liên quan
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)
Ngoc Hong
Xem chi tiết
Minh Lệ
19 tháng 3 2023 lúc 22:29

Câu 1:

Program HOC24;

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

i,n: integer; tbc: real;

begin

write('Nhap so phan tu trong mang: '); readln(n);

for i:=1 to n do

begin

write('Nhap phan tu thu ',i,' : '); readln(a[i]);

end;

tbc:=0;

 

for i:=1 to n do tbc:=tbc+a[i];

tbc:=tbc/n;

write('Trung binh cong la: ',tbc:6:2);

 

readln

end.

Bình luận (0)
Minh Lệ
19 tháng 3 2023 lúc 22:37

Câu 2:

Program HOC24;

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

i,n,h,tg: integer;

begin

write('Nhap so phan tu trong mang: '); readln(n);

for i:=1 to n do

begin

write('Nhap phan tu thu ',i,' : '); readln(a[i]);

end;

for i:=1 to n do

for j:=i to n do

if a[i]>a[j] then

begin

tg:=a[i];

a[i]:=a[j];

a[j]:=tg;

end;

write('Mang sau khi sap xep la: ');

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

readln

end.

Bình luận (0)
Minh Lệ
19 tháng 3 2023 lúc 22:38

Câu 3:

Program HOC24;

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

i,n,h,tg: integer;

begin

write('Nhap so phan tu trong mang: '); readln(n);

for i:=1 to n do

begin

write('Nhap phan tu thu ',i,' : '); readln(a[i]);

end;

for i:=1 to n do

for j:=i to n do

if a[i]<a[j] then

begin

tg:=a[i];

a[i]:=a[j];

a[j]:=tg;

end;

write('Mang sau khi sap xep la: ');

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

readln

end.

Bình luận (0)
bui pham phuong Uyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 1 2021 lúc 13:15

Bài 1: 

uses crt;

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

i,n,kt,max,x,j,tam:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

writeln('Mang ban vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

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 tang dan la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

write('Nhap x='); readln(x);

max:=0;

kt:=0;

for i:=1 to n do 

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

   begin

  if max<a[i] then max:=a[i];

kt:=1;

end;

if kt=0 then writeln('Trong day khong co so le')

else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);

readln;

end.

Bình luận (0)
Phan Thu
Xem chi tiết
Văn Công Sỹ
Xem chi tiết
Văn Công Sỹ
25 tháng 4 2021 lúc 10:28

Làm giúp bài này nhé

 

Bình luận (0)
Bùi Anh Tuấn
25 tháng 4 2021 lúc 19:41

Bình luận (0)
Nguyễn Lê Phước Thịnh
25 tháng 4 2021 lúc 22:19

uses crt;

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

i,n,min,tam,j:integer;

begin

clrscr;

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

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

min:=a[1];

for i:=1 to n do 

  if min>a[i] then min:=a[i];

writeln('Gia tri nho nhat la: ',min);

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)
Linh hoa
Xem chi tiết
Phạm An Khánh
Xem chi tiết
Phạm An Khánh
23 tháng 3 2021 lúc 21:10

đây là pascal ạ

Bình luận (0)
Nguyễn Lê Phước Thịnh
24 tháng 3 2021 lúc 20:20

uses crt;

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

i,n,j,tam,t,t1,tam,dem,max:integer;

begin

clrscr;

n:=0;

t:=0;

repeat

inc(n);

write('A[',n,']='); readln(a[n]);

t:=t+a[n];

until t>100;

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 so theo chieu tang dan la: ');

for i:=1 to n do 

 write(a[i]:4);

writeln;

t1:=0;

dem:=0;

for i:=1 to n do 

if a[i] mod 3=0 then

begin

t1:=t1+a[i];

inc(dem);

end;

max:=a[1];

for i:=1 to n do 

  if max<a[i] then max:=a[i];

writeln('Tong cac so la boi cua 3 la: ',t1);

writeln('So lon nhat cua day la: ',max);

writeln('So luong so la boi cua 3 la: ',dem);

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)
enity704
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 23:01

1:

#include <bits/stdc++.h>

using namespace std;

long long a[100],i,n;

int main()

{

cin>>n;

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

cout<<"Day ban dau la: "<<endl;

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

cout<<endl;

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

cout<<"Day tang dan la: "<<endl;

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

return 0;

}

Bình luận (0)