Những câu hỏi liên quan
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.

Anh Lê duy
Xem chi tiết
Anh Nguyen
Xem chi tiết
Phía sau một cô gái
18 tháng 3 2023 lúc 19:37

N = int(input("Nhập số lượng phần tử của dãy N (>50): "))

while N <= 50:

         N = int(input("Nhập lại số lượng phần tử của dãy N (>50): "))

# Nhập vào dãy số 

danh_sach = []

for i in range(N):

         danh_sach.append(int(input("Nhập số thứ %d: " % (i+1))))

# In ra dãy số vừa nhập

print("Dãy số vừa nhập:")

for i in danh_sach:

         print(i, end=' ')

# Nhập vào số nguyên x

x = int(input("nNhập vào số nguyên x: "))

# In ra các số chia hết cho x 

print("Các số chia hết cho x là:")

for i in danh_sach:

         if i % x == 0:

                  print(i, end=' ')

Long Phan
Xem chi tiết
Khánh Linh
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 2 2022 lúc 20:07

uses crt;

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

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

begin

clrscr;

readln(n);

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

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

writeln;

writeln('Cac so duong la: ');

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

writeln;

t:=0;

for i:=1 to n do 

  if a[i] mod 3=0 then t:=t+a[i];

writeln(t);

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.

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.

Linh hoa
Xem chi tiết
Tạ Quang Dũng
Xem chi tiết
Minh Lệ
4 tháng 5 2023 lúc 11:41

Program HOC24;

var min,j,i,n,tg: integer;

t: longint;

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

begin

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

for i:=1 to n do 

begin

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

end;

t:=0;

for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ') else t:=t+a[i];

writeln; writeln('Tong cac so le la: ',t);

min:=a[1];

for i:=2 to n do if a[i]<min then min:=a[i];

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

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;

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

readln

end.

HT.Phong (9A5)
4 tháng 5 2023 lúc 11:29

Uses crt;

var  i,n,min,k,e,j: longint

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

begin clrscr;

readln(n);

for i:=1 to n do read(n); readln;

for i:=1 to n do if(a[i] mod 2=0) then write(a[i],' ');

for i:=1 to n do if(a[i] mod 2<>0) then k:=k+a[i];

min:=a[i];

for i:=1 to n do if(min>a[i]) then min:=a[i];

writeln(min);

for i:=1 to n-1 do
for j:=i+1 to n do if a[j] <=a[i] then
begin e:= a[i];

a[i]:=a[j];

a[j]:=e; end;
for i:=1 to n do write(a[i],'');

readln;

end.

Kien
Xem chi tiết