Những câu hỏi liên quan
Thảo Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 12 2021 lúc 10:41

#include <bits/stdc++.h>

using namespace std;

long long a[10000],n,i,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>a[i];

t=t+a[i];

}

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

cout<<endl;

dem=0;

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

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

cout<<dem<<endl;

cout<<t;

return 0;

}

Bình luận (0)
Danh Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 7:23

Bài 1:

#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<0) and (x%2!=0)) t=t+x;

}

cout<<t;

return 0;

}

Bình luận (0)
phạm hải nam
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 9:46

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

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

cout<<endl;

t=0;

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

cout<<t;

return 0;

}

Bình luận (0)
nông thị ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 3 2021 lúc 19:41

uses crt;

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

n,i,k,t,t1:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

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

t:=0;

for i:=1 to n do 

  if a[i] mod 2<>0 then t:=t+a[i];

t1:=0;

for i:=1 to n do 

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

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

writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);

readln;

end.

Bình luận (1)
HUY HUỲNH QUANG
Xem chi tiết
Kiều Vũ Linh
5 tháng 5 2023 lúc 14:54

Bài 5:

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

i,n,max:integer;

sc, sl:longint;

Begin

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

For i:=1 to n do

Begin

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

If a[i] mod 2 = 0 then sc:=sc+b[i];

If a[i] mod 2 <> 0 then sl:=sl+a[i];

End;

max:=a[1];

For i:=2 to n do

If a[i] > max then max:=a[i];

Writeln('Tong cac so chan la ',sc);

Writeln('Tong cac so le la ',sl);

write('So lon nhat la ',max);

Readln

End.

Bình luận (1)
Nguyễn tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:09

uses crt;

var a:array[1..10]of longint;

n,i,t,dem,dem1,dem2,t1:integer;

begin

clrscr;

readln(n);

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

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

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

Bình luận (0)
zero
20 tháng 1 2022 lúc 14:08

B

Bình luận (1)
Chanh Xanh
20 tháng 1 2022 lúc 14:08
Bình luận (1)
Nguyễn tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 1 2022 lúc 15:08

uses crt;

var a:array[1..10]of longint;

n,i,t,dem,dem1,dem2,t1:integer;

begin

clrscr;

readln(n);

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

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

writeln;

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

t1:=0;

dem1:=0;

dem2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then dem1:=dem+1;

if a[i] mod 2=0 then 

begin

dem2:=dem2+1;

t1:=t1+a[i];

end;

end;

writeln(dem1);

writeln(t1/dem2:4:2);

readln;

end.

Bình luận (0)
Tiến Đạt Huỳnh
Xem chi tiết
Thanh Phong (9A5)
27 tháng 4 2023 lúc 10:19

Uses crt;

var i,n: longint;

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

begin clrscr;

readln(n);

for i:=1 to n do read(a[i]); 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 write(a[i],'  ');

readln;

end.

Bình luận (2)
duyy
Xem chi tiết
Edward Paros
18 tháng 4 2023 lúc 22:31

program Tinh_Tong_Phan_Tu_Chan;

var
  A: array of Integer;
  N, i, sum: Integer;

begin
  Write('Nhap N: ');
  Readln(N);

  SetLength(A, N);

  // Nhập các phần tử cho mảng A
  for i := 0 to N - 1 do
  begin
    Write('Nhap phan tu thu ', i + 1, ': ');
    Readln(A[i]);
  end;

  // In lên màn hình các phần tử của mảng A
  Write('Cac phan tu cua mang la: ');
  for i := 0 to N - 1 do
  begin
    Write(A[i], ' ');
  end;
  Writeln;

  // Tính tổng các phần tử chẵn của mảng A và thông báo kết quả ra màn hình
  sum := 0;
  for i := 0 to N - 1 do
  begin
    if A[i] mod 2 = 0 then
      sum := sum + A[i];
  end;
  Writeln('Tong cac phan tu chan cua mang la: ', sum);

  Readln;
end.

Bình luận (0)
Huy Hoàng Phạm
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 12 2021 lúc 8:06

#include <bits/stdc++.h>

using namespace std;

long long n,i,a[10000];

int main()

{

cin>>n;

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

cin>>a[i];

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

return 0;

}

Bình luận (0)