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.

14 tháng 3 2023

Program HOC24;

var i,n: integer;

a: array[1..10000] 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 3=0) and (a[i] mod 5=0) then t:=t+a[i];

write('Tong la: ',t);

readln

end.

16 tháng 3 2023
A = int(input('N = ')) if (A >= 0and (A <= 10**3):     i = 0     tong = 0     print (i)     while (i <= 10**3):         i += 1         if (i%3==0and (i%5==0):             if (i <= A):                 tong += i                 print (i)     print (f'Tổng: {tong}')

#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++)

if (a[i]%3==0) t+=a[i];

cout<<t;

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)

13 tháng 3 2023

Var so,n,i:integer;

s:longint;

Begin

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

For i:=1 to n do

Begin

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

If (so mod 3 = 0) and (so mod 5 = 0) then

s:=s+so;

End;

Write('Tong la ',s);

Readln;

End.

23 tháng 12 2020

Câu 1: 

uses crt;

var a:array[1..500]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) and (a[i] mod 7=0) then t:=t+a[i];

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

readln;

end.

Câu 2: 

uses crt;

var c,a:array[1..10]of integer;

i,kt,j,dem:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

write('C[',i,']='); readln(c[i]);

end;

dem:=0;

for i:=1 to 10 do 

  if c[i]>1 then 

begin

kt:=0;

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

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

if kt=0 then 

begin

inc(dem);

a[dem]:=c[i];

end;

end;

if dem=0 then writeln('Trong day khong co so nguyen to')

else begin

writeln('Cac so nguyen to trong day la: ');

for i:=1 to dem do

write(a[i]:4);

end;

readln;

end.

Câu 3: 

uses crt;

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

i,k,dem:integer;

begin

clrscr;

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

for i:=1 to k do 

  begin

write('D[',i,']='); readln(d[i]);

end;

dem:=0;

for i:=1 to k do 

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

writeln('So phan tu chan co 2 chu so la: ',dem);

readln;

end.

16 tháng 4 2023

program BaiToanMang;

var
  A: array[1..100] of integer;
  N, i, demChan, tongLeChia3: integer;

begin
  write('Nhap so phan tu cua mang: ');
  readln(N);
  writeln('Nhap cac phan tu cua mang: ');
  for i := 1 to N do
  begin
    write('a[', i, ']= ');
    readln(A[i]);
  end;
  tongLeChia3 := 0;
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 1) and (A[i] mod 3 = 0) then
    begin
      tongLeChia3 := tongLeChia3 + A[i];
    end;
  end;
  writeln('Tong cac so le chia het cho 3: ', tongLeChia3);
  demChan := 0;
  for i := 2 to N do
  begin
    if (A[i] mod 2 = 0) and (i mod 2 = 1) then
    begin
      demChan := demChan + 1;
    end;
  end;
  writeln('So phan tu chan o vi tri le: ', demChan);
  writeln('Cac so chan chia het cho 5: ');
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 0) and (A[i] mod 5 = 0) then
    begin
      write(A[i], ' ');
    end;
  end;
end.

ko bt đúng ko ko dùng pascal nhiều

16 tháng 4 2023

b dùng pascal hay python V:

10 tháng 4 2021

Program HOC24;

var d,i,n: integer;

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

t: longint;

function nt(x: longint): boolean;

var j: longint;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

begin

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

for i:=1 to n do

begin

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

end;

d:=0; t:=0;

for i:=1 to n do

if nt(a[i]) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' so nguyen to trong day');

write('Tong cac so nguyen to trong day la: ',t);

readln

end.

uses crt;

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

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

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

dem:=0;

t:=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

begin

inc(dem);

t:=t+a[i];

end;

end;

writeln('So luong so nguyen to la: ',dem);

writeln('Tong cac so nguyen to la: ',t);

readln;

end.