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;
long long x,n,i,k,t;
int main()
{
cin>>n>>k;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%k==0) t+=x;
}
cout<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t,k:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
readln(k);
t:=0;
for i:=1 to n do
if a[i] mod k=0 then t:=t+a[i];
writeln(t);
readln;
end.
Uses crt;
Var A: array[1..100] of longint;
n,k,i,s: longint;
Begin
Clrscr;
Write(‘Nhap n,k: ‘); Readln(n,k);
s:=0;
For i:=1 to n do
Begin
Read(A[i]);
If A[i] mod k = 0 then s:=s+A[i];
End;
Write(s);
Readln
End.
uses crt;
var x,i,n,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
begin
readln(x);
if x<>0 then t:=t+x;
end;
write(t);
readln;
end.
uses crt;
var a:array[1..250]of integer;
n,i,t,max,min: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 3=0 then t:=t+a[i];
writeln('Tong cac so la boi cua 3 la: ',t);
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
readln;
end.
program tim_so_nguyen_am;
uses crt;
var n,i:integer;
b:array[1..1000]of integer;
begin
clrscr;
write('nhap so phan tu :');readln(n);
repeat
for i:=1 to n do
begin
write('nhap phan tu b[',i,']:');readln(b[i]);
end;
if abs(a[i]>1000)then write('ban hay nhap lai:');
until abs(b[i]<=1000);
writeln('cac phan tu nguyen duong cua mang la:');
for i:=1 to n do
if b[i]>=0 then write(b[i]:5);
writeln;
writeln('cac phan tu nguyen am cua mang la:');
readln;
end.
for i:=1 to n do
if b[i]<0 then write(b[i]:5);
uses crt;
var b:array[1..25]of integer;
i,n,dem1,dem2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if b[i]>0 then inc(dem1);
if b[i]<0 then inc(dem2);
end;
writeln('So cac so nguyen duong la: ',dem1);
writeln('So cac so nguyen am la: ',dem2);
readln;
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;
}
program so_lon_nhat;
uses crt;
var a: array[1..100] of integer;
i,n,max,k,dem: integer;
s,tbc: real;
begin
clrscr;
writeln(' nhap so phan tu cua day'); readln(n);
for i:=1 to n do
begin
writeln('a[',i,']'); readln(a[i]);
end;
writeln(' nhap so can tim:'); readln(k);
max:=a[1];
i:=1;
dem:=0;
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
s:=s+a[i];
tbc:=s/n;
if a[i]=k then dem:=dem+1;
end;
writeln(' so lon nhat trong day tren la:',max);
while (i<n) and (a[i]<>k) do i:=i+1;
if a[i]=k then writeln(' phan tu thu ', i ,' bang ',k)
else writeln(' k tim dc phan tu',k);
writeln(tbc:6);
writeln('co', dem, ' phan tu', k);
readln
end.
uses crt;
var a:array[1..100]of integer;
n,i,k,t:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
until abs(a[i])<=300;
end;
write('nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod k=0 then t:=t+a[i];
writeln('Tong cac so la boi cua ',k,' trong day la: ',t);
readln;
end.