Những câu hỏi liên quan
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)
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)
༺ミ𝒮σɱєσиє...彡༻
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)
Thắng Lee
Xem chi tiết
Tiên Tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
27 tháng 1 2021 lúc 23:08

uses crt;

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

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

writeln('Day so xep giam dan la: ');

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

readln;

end.

Bình luận (0)
Huỳnh Tiến Thiên
Xem chi tiết
HSNK HSG
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 10 2021 lúc 0:01

uses crt;

var a:array[1..50]of int64;

i,n,t,max,min:int64;

begin

clrscr;

readln(n);

for i:=1 to n do 

  readln(a[i]);

max:=a[1];

min:=a[1];

t:=0;

for i:=1 to n do 

begin

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

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

t:=t+a[i];

end;

writeln('Tong la: ',t);

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

write('Vi tri la: ');

for i:=1 to n do

if a[i]=max then write(i:4);

writeln;

writeln('So nho nhat la: ',min);

write('Vi tri la: ');

for i:=1 to n do 

if a[i]=min then write(i:4);

readln;

end.

Bình luận (0)
Khánh Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
25 tháng 2 2022 lúc 8:21

#include <bits/stdc++.h>

using namespace std;

long long a[10000],i,n;

int main()

{

cin>>n;

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

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

cout<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t+=a[i];

cout<<"Tong cac so chan la: "<<t<<endl;

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

cout<<"Day so giam dan la: ";

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

return 0;

}

Bình luận (1)
Phụng Lã
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 12 2022 lúc 14:42

#include <bits/stdc++.h>

using namespace std;

int A[500],n,i,dem,dem1;

int main()

{

cin>>n;

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

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

cout<<endl;

dem=0;

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

if (A[i]<10) dem++;

cout<<dem<<endl;

dem1=0;

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

if (A[i]>1)

{

bool kt=true;

for (int j=2; j*j<=A[i]; j++)

if (A[i]%j==0) kt=false;

if (kt==true) dem1++;

}

cout<<dem1;

return 0;

}

Bình luận (0)