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;

}

uses crt;

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

i,n,max,dem:integer;

begin

clrscr;

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

for i:=1 to n do

 begin

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

end;

max:=a[1];

for i:=1 to n do 

  if max<a[i] then max:=a[i];

writeln('Gia tri lon nhat la: ',max);

dem:=0;

for i:=1 to n do 

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

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

readln;

end.

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.

17 tháng 5 2021

Program HOC24;

var n,d,i: integer;

B: array[1..100] of integer;

t: longint;

begin

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

for i:=1 to n do 

begin

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

end;

d:=0; t:=0;

for i:=1 to n do 

if b[i]>0 then

begin

d:=d+1;

t:=t+b[i];

end;

writeln('Tong cac so duong trong day so la: ',t);

write('Co ',d,' so duong trong day');

readln

end.

7 tháng 6 2021

uses crt;
var b:array[1..100] of longint;
      n,i,d,s:longint;
begin
      clrscr;
      write('n='); readln(n);
      for i:=1 to n do 
            begin
                  write('a[',i,']: '); readln(b[i]);
                  if b[i]>0 then begin
                        inc(d);
                        inc(s,b[i]);
                  end;
            end;
      writeln('Tong cac so duong: ',s);
      writeln('Co ',d,' so duong');
      readln;
end.

25 tháng 4 2023

program dem;

var

      n, i, chan, le: integer;

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

begin

      write('Nhap so phan tu cua day: ');

      readln(n);

      for i := 1 to n do

      begin

            write('Nhap phan tu thu ', i, ': ');

            readln(a[i]);

      end;

      chan := 0;

      le := 0;

      for i := 1 to n do

      begin

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

                  chan := chan + 1

            else

                  le := le + 1;

      end;

      writeln('So phan tu chan trong day la: ', chan);

      writeln('So phan tu le trong day la: ', le);

end.