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.

15 tháng 5 2020

Bài 2:

Program HOC24;

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

i,n: integer;

t: longint;

begin

write('Nhap so phan tu cua day : '); 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] 0 then t:=t+a[i];

write('Tong cac phan tu khong am trong mang nguyen la ',t);

readln

end.

15 tháng 5 2020

Bài 1:

Program HOC24;

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

i,n,d: integer;

begin

write('Nhap so phan tu cua day : '); readln(n);

for i:=1 to n do

begin

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

end;

d:=0;

for i:=1 to n do

if a[i] mod 3<>0 then inc(d);

write('Co ',d,' phan tu khong chia het cho 3 trong mang');

readln

end.

Bài 1:

uses crt;

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

i,n,dem:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

dem:=0;

for i:=1 to n do

if a[i] mod 3<>0 then inc(dem);

writeln('So phan tu khong chia het cho 3 trong day la: ',dem);

readln;

end.

Bài 2:

uses crt;

var a:array[1..250]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;

t:=0;

for i:=1 to n do

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

writeln('Tong cac phan tu khong am trong day la: ',t);

readln;

end.

15 tháng 3 2021

const fi='dl.pas';

fo='qk.pas';

var f1,f2:text;

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

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

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

dem:=0;

for i:=1 to n do 

  if (a[i] mod 2<>0) and (a[i] mod 7=0) then inc(dem);

t:=0;

for i:=1 to n do

  if (10<=a[i]) and (a[i]<=30) then t:=t+a[i];

dem1:=0;

for i:=1 to n do 

  if (a[i]<0) and (a[i] mod 2<>0) then inc(dem1);

dem2:=0;

for i:=1 to n do 

  if a[i]>1 then

begin

kt:=0;

for j:=2 to a[i]-1 do 

  if a[i] mod j=0 then kt:=1;

if kt=0 then inc(dem2);

end;

writeln(f2,'So phan tu le chia het cho 7 la: ',dem);

writeln(f2,'Tong cac phan tu thuoc [10,30] la: ',t);

writeln(f2,'So cac phan tu am le la: ',dem1);

writeln(f2,'So phan tu la so nguyen to la: ',dem2);

close(f1);

close(f2);

end.

#include <bits/stdc++.h>

using namespace std;

double a[100],t1,t2,k;

int i,n,dem;

int main()

{

cin>>n;

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

cin>>k;

dem=0;

for (i=1; i<=n; i++) if (a[i]==k) dem++;

t1=0;

t2=0;

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

{

if (a[i]>0) t1+=a[i];

else t2+=a[i];

}

cout<<dem<<endll;

cout<<t1<<" "<<t2;

return 0;

}

14 tháng 4 2023

# Nhập mảng A từ bàn phím
n = int(input("Nhập số lượng phần tử của mảng A: "))
A = []
for i in range(n):
    A.append(int(input("Nhập phần tử thứ {} của mảng A: ".format(i+1))))

# Tính trung bình cộng các phần tử chia hết cho 3 và 5
sum_35 = 0
count_35 = 0
for num in A:
    if num % 3 == 0 and num % 5 == 0:
        sum_35 += num
        count_35 += 1
if count_35 > 0:
    tb_35 = sum_35 / count_35
    print("Trung bình cộng các phần tử chia hết cho 3 và 5 trong mảng A là:", tb_35)
else:
    print("Không có phần tử nào chia hết cho cả 3 và 5 trong mảng A")

# In ra các phần tử chia hết cho M và tính tổng các phần tử chia hết cho M
M = int(input("Nhập giá trị M: "))
sum_M = 0
count_M = 0
for num in A:
    if num % M == 0:
        print(num, end=" ")
        sum_M += num
        count_M += 1
print("\nTổng các phần tử chia hết cho M trong mảng A là:", sum_M)

#include <bits/stdc++.h>

using namespace std;

long long a[20],n=20,i,dem,t,s;

int main()

{

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

dem=0;

for (i=1; i<=n; i++) if (a[i]%9==2) dem++;

t=0;

for (i=1; i<=n; i++) if (a[i]%5==0) t+=a[i];

s=1;

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

if (a[i]%7==0) s*=a[i];

cout<<dem<<endl;

cout<<t<<endl;

cout<<s;

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,dem1,dem2,t1,t2;

int main()

{

cin>>n;

dem1=0;

dem2=0;

t1=0;

t2=0;

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

{

cin>>x;

if (x>0)

{

dem1++;

t1+=x;

}

if (x<0)

{

dem2++;

t2+=x;

}

}

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

cout<<t1<<" "<<t2;

return 0;

}