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;
}
#include <bits/stdc++.h>
using namespace std;
long long a[200],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
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.
Câu 2:
uses crt;
var a:array[1..300]of integer;
i,n,t:integer;
begin
clrscr;
randomize;
cin>>n;
for i:=1 to n do a[i]:=random(500);
t:=0;
for i:=1 to n do if a[i]=150 then t:=t+a[i];
writeln(t);
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.
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;
i,n,tc,tl,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tc:=0;
tl:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then tc:=tc+a[i]
else tl:=tl+a[i];
end;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
readln;
end.
giờ mình với là gì vậy =)?
chắc là"giúp mk với"đó