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.

4 tháng 3 2021

program trungbinhcong;

uses crt;

var a: array[1..80]of integer;      tb: real;      tong: integer;      i,n,sl: byte; begin clrscr; writeln('nhap n: '); readln(n); for i:= 1 to n do    begin        writeln('nhap a[',i,']: ');        readln(a[i]);    end; tong:=0; sl:=0; for i:= 1 to n do    if (a[i] mod 2 <> 0) then        begin            sl:=sl+1;            tong:=tong+a[i];        end; tb:=tong/sl; writeln('trung binh cong cua cac phan tu le trong mang la: ', tb:4:3); readlnend.

#include <bits/stdc++.h>

using namespace std;

long long n,i,nn,t1,t2,dem1,dem2,a[1000];

int main()

{

cin>>n;

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

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn<<endl;

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

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

cout<<endl;

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

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

cout<<endl;

t1=0;

t2=0;

dem1=0;

dem2=0;

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

{

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

{

t1+=a[i];

dem1++;

}

else 

{

t2+=a[i];

dem2++;

}

}

cout<<t1<<" "<<dem1<<endl;

cout<<t2<<" "<<dem2;

return 0;

}

20 tháng 2 2022

tham khảo

 

#include <bits/stdc++.h>

using namespace std;

long long n,i,nn,t1,t2,dem1,dem2,a[1000];

int main()

{

cin>>n;

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

nn=a[1];

for (i=1; i<=n; i++) nn=min(nn,a[i]);

cout<<nn<<endl;

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

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

cout<<endl;

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

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

cout<<endl;

t1=0;

t2=0;

dem1=0;

dem2=0;

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

{

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

{

t1+=a[i];

dem1++;

}

else 

{

t2+=a[i];

dem2++;

}

}

cout<<t1<<" "<<dem1<<endl;

cout<<t2<<" "<<dem2;

return 0;

}

uses crt;

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

i,n,min,t1,t2,dem1,dem2:integer;

begin

clrscr;

readln(n);

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

min:=a[1];

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

writeln(min);

writeln('Cac so chan la: ');

for i:=1 to n do 

if a[i] mod 2=0 then write(a[i]:4);

writeln;

writeln('Cac so le la: ');

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

writeln;

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(t1,' ',t2);

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

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

else dem2:=dem2+1;

end;

writeln(dem1,' ',dem2);

readln;

end.

uses crt;

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

i,n,tb:integer;

begin

clrscr;

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

for i:=1 to n do 

 begin

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

end;

tb:=0;

for i:=1 to n do 

  tb:=tb+a[i];

writeln('Trung binh cua day so la: ',tb:4:2);

writeln('Cac so lon hon gia tri trung binh la: ');

for i:=1 to n do 

  if a[i]>tb then write(a[i]:4);

readln;

end.

29 tháng 11 2021

Tham khảo

 

uses crt;

var n,i,ta,td,d1,d2:integer;

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

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

td:=0;

d1:=0;

for i:=1 to n do

if a[i]>0 then

begin

td:=td+a[i];

inc(d1);

end;

writeln('Trung binh cong cac so duong la: ',td/d1:4:2);

d2:=0;

ta:=0;

for i:=1 to n do

if a[i]<0 then

begin

inc(d2);

ta:=ta+a[i];

end;

writeln('Trung binh cong cac so am la: ',ta/d2:4:2);

readln;

end.

29 tháng 4 2023

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.

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

if (x%2!=0) t=t+x;

}

cout<<t;

return 0;

}

Bài 1: 

uses crt;

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

i,n: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 do 

  if a[i] mod 2<>0 then write(a[i]:4);

readln;

end.

Bài 2: 

uses crt;

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

i,n: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 do

  if a[i] mod 2=0 then write(a[i]:4);

readln;

end.

11 tháng 5 2022

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

i,n,s:integer;

tbc:real;

Begin

Write('Nhap so luong so n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');readln(a[i]);

s:=s+a[i];

End;

tbc:=s/n;

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

Readln;

End.