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.

Bình luận (0)
Ánh sao
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 4 2021 lúc 20:15

Câu 1: 

uses crt;

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

max,i:integer;

begin

clrscr;

for i:=1 to 5 do 

  begin

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

end;

max:=a[1];

for i:=1 to 5 do 

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

writeln(max);

readln;

end.

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

Câu 2: 

uses crt;

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

min,i:integer;

begin

clrscr;

for i:=1 to 6 do 

  begin

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

end;

min:=a[1];

for i:=1 to 6 do 

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

writeln(min);

readln;

end.

Bình luận (0)
Phạm Kiều Oanh
Xem chi tiết
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.

Bình luận (0)
hoho209
19 tháng 3 2021 lúc 0:35

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

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)
Lee lee
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 4 2021 lúc 22:13

uses crt;

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

i,n,max,min:integer;

begin

clrscr;

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

for i:=1 to n do 

 begin

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

end;

max:=a[1];

min:=a[1];

for i:=1 to n do

begin

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

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

end;

writeln('Gia tri lon nhat la: ',max);

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

readln;

end.

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

6:

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,A[100],i,dem=0;

cin>>n;

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

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

if (A[i]%2!=0) dem++;

cout<<dem;

return 0;

}

5:

#include <bits/stdc++.h>

using namespace std;

int main()

{

long long n,nn=1e6,A[1000];

cin>>n;

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

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

nn=min(nn,A[i]);

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

if (nn==A[i]) cout<<i<<" ";

return 0;

}

Bình luận (0)
feng
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 5 2022 lúc 10:07

uses crt;

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

n,i,t,nn,kt:integer;

begin

clrscr;

readln(n);

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

t:=1;

for i:=1 to n do 

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

writeln(t);

kt:=0;

nn:=32567;

for i:=1 to n do 

  if a[i] mod 3=0 then 

begin

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

kt:=1;

end;

if kt=0 then writeln('Khong co so chia het cho 3')

else writeln('So nho nhat chia het cho 3 la: ',nn);

for i:=1 to n do 

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

writeln;

for i:=n downto 1 do 

  write(a[i]:4);

readln;

end.

Bình luận (1)
bảo nhi
Xem chi tiết
Kiều Vũ Linh
29 tháng 4 2023 lúc 11:12

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

i,n:integer;

s:longint;

tbc:real;

Begin

Repeat

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

Until (n>0) and (n<=100);

For i:=1 to n do

Begin

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

s:=s+a[i];

End;

tbc:=s/n;

Write('Trung binh cong la ',tbc:10:2);

Readln

End.

Bình luận (0)