K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

13 tháng 3 2021

Program HOC24;

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

i,n,tg,c,l: integer;

tc,tl: longint;

begin

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

c:=0; l:=0; tc:=0; tl:=0;

for i:=1 to n do

begin

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

if a[i] mod 2=0 then

begin

c:=c+1;

tc:=tc+a[i];

end;

if a[i] mod 2=1 then

begin

l:=l+1;

tl:=tl+a[i];

end;

end;

write('Day da sap xep: ');

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

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

writeln;

wirteln('Co ',l,' so le');

writeln('Co ',c,' so chan');

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

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

readln

end.

27 tháng 3 2022

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.

4 tháng 5 2023

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.

4 tháng 5 2023

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.

17 tháng 6 2021

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.

28 tháng 4 2021

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.

28 tháng 4 2021

thank

25 tháng 4 2023

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.

11 tháng 4 2021

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.

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.

#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;

}

#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;

}