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.

20 tháng 4 2020

Program hotrotinhoc;

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

i,n,t: integer;

begin

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

for i:=1 to n do

begin

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

end;

t:=0;

for i:=1 to n do

if b[i] mod 5=0 then t:=t+b[i];

write('Tong cac phan tu co gia tri chia het cho 5 trong mang B la : ',t);

readln

end.

21 tháng 1 2022

viết chương trình chứ không phải chọn đáp án 

#include <bits/stdc++.h>

using namespace std;

long long a[100],n,i,t,t1,dem,dem1;

//chuongtrinhcon

bool ktnt(long long x)

{

if (x<=1) return(false);

for (int i=2; i*i<=x; i++)

if (x%i==0) return(false);

return true;

}

//chuongtrinhchinh

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++) if (a[i]%2==0) t=t+a[i];

cout<<t<<endl;

dem=0;

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

cout<<dem<<" ";

t1=0;

dem1=0;

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

if (a[i]%2!=0)

{

t1+=a[i];

dem1++;

}

cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;

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

if (ktnt(a[i])==true) cout<<a[i]<<" ";

return 0;

}

24 tháng 12 2021

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

}

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.

20 tháng 1 2022

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.

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)

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.

20 tháng 12 2021

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

}

24 tháng 11 2021

bprogram min 

uses crt 

var A: array [1...250] of integer

tong :integer;

begin 

tong:=0

writeln(‘nhap n:’); readln (n) 

forr i:=1 to n do 

begin 

writeln (‘nhap phan tu thu ‘,i);

readln (A[i] );

end

for i:=1 to n do 

begin

if (A[i] mod 3=0) 

then tong:=tong +A[i];

end

writeln (Tong cac phan tu chia het cho 3) 

readln ;

end

24 tháng 11 2021
24 tháng 12 2021

Đề thiếu rồi bạn

3 tháng 4 2022

uses crt;

var C : array [1 .. 50] of integer;

i, n : integer;

begin

clrscr;

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

write('Nhap day gom ', n ,' so : ');

for i := 1 to n do read(C[i]);

write('Cac gia tri chan : ');

for i := 1 to n do

if C[i] mod 2 = 0 then write(C[i], ' ');

readln

end.

 

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.

18 tháng 12 2021

Câu 3: Nhập một mảng gồm N phần tử.

A, tính tổng chẵn, tổng lẻ của các phấn tử trong mảng.

B, Tìm phần tử lớn nhất, nhỏ nhất trong mảng.

C, Tìm kiếm xem phần tử K nào đó có tồn tại trong mảng hay không?