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.

 

 

#include <bits/stdc++.h>

using namespace std;

int A[1000],n,t=0;

int main()

{

cin>>n;

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

cin>>A[i];

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

if (A[i]%5==0 && A[i]>0) t+=A[i];

cout<<t;

return 0;

}

31 tháng 12 2022

#include <bits/stdc++.h>

using namespace std;

int n,A[100],i,k,t;

int main()

{

cin>>n>>k;

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

t=0;

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

if (A[i]%k==0) t+=A[i];

cout<<t;

}

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t1,t2,t3;

int main()

{

cin>>n;

t1=0; t2=0; t3=0;

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

{

cin>>x;

t1+=x;

if (x%2==0) t2+=x;

else t3+=x;

}

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

return 0;

}

#include <bits/stdc++.h>

using namespace std;

long long a[150],i,s,n,nn;

int main()

{

cin>>n;

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

s=1;

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

if (a[i] %2!=0 && a[i]%3==0) s=s*a[i];

cout<<s<<endl;

nn=a[1];

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

for (i=n; i>=1; i--) 

if (nn==a[i]) 

{

cout<<i<<endl;

break;

}

sort(a+1,a+n+1);

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

return 0;

}

11 tháng 5 2022

tham khảo'

 

uses crt;

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

i,n,t,dem:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then

begin

t:=t+a[i];

inc(dem);

end;

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

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

readln;

end.

11 tháng 5 2022

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

i,n,dem,vt,s sc,sl,min:integer;

tbc:real;

Begin

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

For i:=1 to n do

Begin

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

End;

For i:=1 to n do s:=s+a[i];

tbc:=s/n;

Writeln('Gia tri trung binh cua mang la ',tbc:10:2);

Write('Cac phan tu lon hon gia tri trung binh la ');

For i:=1 to n do

If a[i]>tbc then write(a[i],'   ');

For i:=1 to n do

Begin

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

Else sl:=sl+a[i];

End;

Writeln('Tong cac phan tu chan la ',sc);

Writeln('Tong cac phan tu le la ',sl);

min:=a[1];

For i:=2 to n do

Begin

If a[i] < min then min:=a[i];

vt:=i;

End;

Writeln('Phan tu nho nhat la ',min,' tai vi tri ',vt);

For i:=1 to n do

If a[i] mod 5 = 0 then dem:=dem+1;

Write('So cac phan tu chia het cho 5 la ',dem);

Readln;

End.

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)

uses crt;

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

i,n,dem:integer;

begin

clrscr;

n:=5;

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 2=0) and (a[i] mod 5=0) then inc(dem);

writeln(dem);

readln;

end.

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

}

Bài 1: 

uses crt;

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

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

readln;

end.

Bài 2: 

uses crt;

var st:string;

d,i:integer;

begin

clrscr;

write('Nhap xau:'); readln(st);

d:=length(st);

for i:=1 to d do 

  if st[i]=#32 then delete(st,i,1);

writeln(st);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

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

{

cin>>x;

if (x%2==0 && x>10) t+=x;

if (x%2!=0 || x<100) dem++;

}

cout<<t<<" "<<dem;

return 0;

}