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.

uses crt;

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

i,n,dem:integer;

begin

clrscr;

readln(n,k);

for i:=1 to n do readln(a[i]);

dem:=0;

for i:=1 to n do

if a[i]<0 then inc(dem);

write(dem);

readln;

end.

14 tháng 2 2022

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. 

uses crt;

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

i,n,dem1,dem2,t1,dem3,j,kt:integer;

begin

clrscr;

readln(n);

for i:=1 to n do 

  readln(a[i]);

dem1:=0;

dem2:=0;

t1:=0;

for i:=1 to n do 

  begin

if a[i] mod 2=0 then 

begin

dem1:=dem1+1;

t1:=t1+a[i];

end;

else dem2:=dem2+1;

end;

dem3:=0;

for i:=1 to n do 

  if (a[i]>1) then 

begin

kt:=0;

for j:=2 to trunc(sqrt(a[i])) do 

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

if kt=0 then dem3:=dem3+1;

end;

writeln(dem1, ' ',dem2);

writeln(t1);

writeln(dem3);

readln;

end.

undefined

Theo C++ nhé bạn

Codeblacks 

uses crt;

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

i,n,dem:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

repeat

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

until a[i]>0;

end;

writeln('Day so vua nhap la: ');

for i:=1 to 10 do 

  write(a[i]:4);

dem:=0;

for i:=1 to n do 

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

writeln;

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

readln;

end.

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

dem=0;

t=0;

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

{

cin>>x;

if (x%3==0) 

{

dem++;

t+=x;

}

}

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

return 0;

}

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.

19 tháng 2 2023

Bài 1:

Program HOC24;

var i,n,d : byte;

t: integer;

begin

write('Nhap 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 if (a[i] mod 3=0) and (a[i] mod 5=0) then

begin

d:=d+1;

t:=t+a[i];

end;

writeln('Co ',d,' phan tu la boi cua 3 va 5');

write('Tong la: ',t);

readln

end.

19 tháng 2 2023

Bài 2:

Program HOC24;

var i,n,k : byte;

begin

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

for i:=1 to n do 

begin

write('Nhap phan tu thu ',i,' : '); readln(a[i]);

end;

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

for i:=1 to n do if a[i]=k then d:=d+1;

writeln('Co ',d,' phan tu bang ',k);

Write('Cac chi so do la: ');

for i:=1 to n do if a[i]=k then write(i,' ');

readln

end.

#include <bits/stdc++.h>

using namespace std;

long long a[20],i,j,dem;

bool kt;

int main()

{

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

dem=0;

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

if (a[i]>1) 

{

kt=true;

for (j=2; j<=sqrt(a[i]); j++)

if (a[i]%j==0) kt=false;

if (kt==true) dem++;

}

cout<<dem;

return 0;

}

6 tháng 1 2022

có lộn ko bạn