Những câu hỏi liên quan
Sarah Lilia
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2021 lúc 20:53

uses crt;

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

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

s:real;

begin

clrscr;

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

for i:=1 to n do 

begin

repeat

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

until a[i]>0;

end;

for i:=1 to n do 

  write(a[i]:4);

writeln;

dem:=0;

for i:=1 to n do

  if a[i]>10 then inc(dem);

writeln('So phan tu lon hon 10 la: ',dem);

dem1:=0;

dem2:=0;

for i:=1 to n do 

begin

if a[i] mod 2=0 then inc(dem1)

else inc(dem2);

end;

writeln('So luong so chan la: ',dem1);

writeln('So luong so le la: ',dem2);

t:=0;

s:=1;

for i:=1 to n do 

  begin

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

if (i mod 2=1) and (a[i] mod 2=0) then s:=s*a[i];

end;

writeln('Tong cac so o vi tri chan co gia tri le la: ',t);

writeln('Tich cac so o vi tri le co gia tri chan la: ',s:4:2);

writeln('Cac so le la: ');

for i:=1 to n do 

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

writeln;

writeln('Cac so chan va lon hon 10 la: ');

for i:=1 to n do 

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

readln;

end.

Bình luận (1)
Nguyễn Thị Linh
Xem chi tiết
Minh Lệ
6 tháng 1 2022 lúc 21:03

Program HOC24;

var i,n: byte;

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

t: longint;

begin

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

for i:=1 to n do

begin

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

end;

t:=0;

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

write('Tong cac so chan la: ',t);

readln

end.

Bình luận (0)
Phong Vũ
Xem chi tiết
Nguyễn Lê Phước Thịnh
1 tháng 3 2022 lúc 13:50

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

t=0;

dem=0;

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

if ((a[i]>0) and (i%2==1))

{

t+=a[i];

dem++;

}

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

return 0;

}

Bình luận (0)
HUỲNH NGỌC BẢO ÂN
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 7:10

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

t=0;

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

if (a[i]%2==0 && i%2==1) t+=a[i];

cout<<t;

return 0;

}

Bình luận (0)
Đạt Trần
Xem chi tiết
Nguyễn Lê Phước Thịnh
18 tháng 5 2021 lúc 9:49

uses crt;

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

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

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  if a[i] mod 7=0 then t:=t+a[i];

writeln('Tong cac so chia het cho 7 la: ',t);

readln;

end. 

Bình luận (0)
Thái Bảo
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 12 2020 lúc 20:08

uses crt;

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

i,n,tc,tl,t:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

tc:=0;

tl:=0;

for i:=1 to n do 

  begin

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

else tl:=tl+a[i];

end;

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

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

t:=0;

for i:=1 to n do  

t:=t+a[i];

writeln('Tong cua day so la: ',t);

readln;

end. 

Bình luận (1)
hà phương
Xem chi tiết
Nguyễn Hoàng Tiến
29 tháng 7 2023 lúc 11:21

đitf

Bình luận (0)
Bao Duong
Xem chi tiết
My meme
Xem chi tiết
Phía sau một cô gái
11 tháng 3 2023 lúc 16:03

n = int(input("Nhập số phần tử của mảng: "))

arr = []

for i in range(n):

     arr.append(int(input("Nhập phần tử thứ " + str(i+1) + ": ")))

even_arr = []

odd_arr = []

for num in arr:

     if num % 2 == 0:

          even_arr.append(num)

     else:

          odd_arr.append(num)

new_arr = even_arr + odd_arr

print("Mảng mới: ", new_arr)

Bình luận (0)