Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Nguyễn Hồng Anh
Xem chi tiết
chuche
27 tháng 3 2022 lúc 15:17

Tham Khảo:

uses crt;

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

i,n,j,tam:integer;

begin

clrscr;

write('Nhap n='); readln(n);</p><p>for i:=1 to n do</p><p>  begin</p><p>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.

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.

Minasua Yagami
Xem chi tiết
Trần Ái Linh
17 tháng 6 2021 lúc 16:59

program im_14424;

uses crt;

var A: array[1..9999999] of interger;

S,P : integer;

i,n: byte;

begin

clrscr;

S:=0;

P:=0;

for i:=1 to n do

begin

write('Nhap vao phan tu thu: ',i,);

readln(A[i]);

S:=S+A[i]

P:=P*A[i]

end;

writeln(S);

write(P);

readln;

end.

nguyensonbd
Xem chi tiết
Nguyen Hung
28 tháng 4 2021 lúc 21:04

Program Tin_hoc;

Uses crt;

Var i,tam,n,chan,le,j:integer;

      a,daychan,dayle:array[1..10000] of integer;

Begin

clrscr;

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

chan:=0;le:=0;

Writeln('Nhap ',n,' phan tu cua mang:');

For i:= 1 to n do 

Begin

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

Readln(a[i]);

If a[i] mod 2 = 0 then 

  Begin

  inc(chan);

  daychan[chan]:=a[i];

  end

else

  Begin

  inc(le);

  dayle[le]:=a[i];

  End;

End;

For i:= 1 to chan do

  for j:= i to chan do If daychan[i]>daychan[j] then 

  Begin

  tam:=daychan[i];

  daychan[i]:=daychan[j];

  daychan[j]:=tam;

  End;

For i:= 1 to le do

  for j:= i to le do If dayle[i]<dayle[j] then 

  Begin

  tam:=dayle[i];

  dayle[i]:=dayle[j];

  dayle[j]:=tam

  End;

Writeln('Day sau khi sap xep:');

For i:= 1 to chan do write(daychan[i],'  ');

For i:= 1 to le do write(dayle[i],'  ');

Readln;

End.

Lê Nguyễn Ánh Nguyệt
Xem chi tiết
Minh Lệ
25 tháng 4 2023 lúc 19:55

Program HOC24;

var i,n: integer;

t1,t2: longint;

begin

write('Nhap so phan tu cua day: '); readln(a[i]);

for i:=1 to n do

begin

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

end;

t1:=0; t2:=0;

for i:=1 to n do if a[i] mod 2=0 then t1:=t1+a[i] else t2:=t2+a[i];

writeln('Tong cac so chan la: ',t1);

write('Tong cac so le la: ',t2);

readln

end.

Ngáo Ngơ Alice
Xem chi tiết
nguyễn an phát
11 tháng 4 2021 lúc 12:02

program timtich;

uses  crt;

var i,n:integer;

tich:longint;

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

begin

clrscr;

write('nhap so n:');readln(n);

for i:=1 to n do

begin

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

end;

for i:=1 to n do

write(a[i]:4);

tich:=1;

writeln;

for i:=1 to n do

if a[i] mod 2=0 then tich:=tich*a[i];

writeln('tich ca phan tu chan cua mang la:',tich);

readln;

end.

program timtong;

uses  crt;

var i,n:integer;

tong:longint;

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

begin

clrscr;

write('nhap so n:');readln(n);

for i:=1 to n do

begin

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

end;

for i:=1 to n do

write(a[i]:4);

tong:=0;

writeln;

for i:=1 to n do

if a[i] mod 2=0 then tong:=tong+a[i];

writeln('tong cac phan tu chan cua mang la:',tong);

tong:=0;

writeln;

for i:=1 to n do

if a[i] mod 2=1 then tong:=tong+a[i];

writeln('tong cac phan tu le cua mang la:',tong);

readln;

end.

Nguyễn Lê Phước Thịnh
11 tháng 4 2021 lúc 17:56

Bài 1: 

uses crt;

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

i,n,s:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

s:=1;

for i:=1 to n do 

  if a[i] mod 2=0 then s:=s*a[i];

writeln(s);

readln;

end.

Nguyễn Lê Phước Thịnh
11 tháng 4 2021 lúc 17:57

uses crt;

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

i,n,t1,t2:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

t1:=0;

t2:=0;

for i:=1 to n do

begin

if a[i] mod 2=0 then t1:=t1+a[i]

else t2:=t2+a[i];

end;

writeln('Tong cac so chan la: ',t1);

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

readln;

end.

Miner Đức
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 1 2022 lúc 11:42

#include <bits/stdc++.h>

using namespace std;

long long a[1000],dem1,dem2,i,n;

int main()

{

cin>>n;

dem1=0;

dem2=0;

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

{

cin>>a[i];

if (a[i]%2==0) dem1++;

else dem2++;

}

cout<<dem1<<" "<<dem2<<endl;

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

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

return 0;

}

Hoàng Anh Quân
Xem chi tiết
Nhảy chân sáo mà từ từ đ...
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:38

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

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

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

cout<<endl;

t=0;

dem=0;

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

if (a[i]%2==0)

{

t=t+a[i];

dem++;

}

cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0)<<endl;

t1=0;

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

if (a[i]%2!=0 || a[i]%3==0) t1+=a[i];

cout<<t1;

return 0;

}