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.

14 tháng 4 2022

trên c++

 

2:

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i,dem;

int main()

{

cin>>n;

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

dem=0;

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

if (a[i]%2==0 && a[i]<0) dem++;

cout<<dem;

return 0;

}

Câu 1:

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

Câu 2: 

uses crt;

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

i:integer;

begin

clrscr;

for i:=1 to 10 do 

  begin

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

end;

for i:=1 to 10 do 

 write(a[i]:4);

readln;

end.

Câu 3: 

uses crt;

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

i,n,t:integer;

begin

clrscr;

repeat

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

until (0<n) and (n<=15);

for i:=1 to n do 

begin

repeat

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

until a[i]<=100;

end;

writeln('Mang da nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do

if a[i] mod 3=0 then t:=t+a[i];

writeln('Tong cac phan tu chia het cho 3 la: ',t);

writeln('Cac so chan o vi tri le trong day la: ');

for i:=1 to n do 

  if (a[i] mod 2=0) and (i mod 2=1) then write(a[i]:4);

readln;

end.

uses crt;

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

n,i,k,dem,dem1: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);

dem:=0;

dem1:=0;

for i:=1 to n do 

  begin

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

if a[i] mod k=0 then inc(dem1);

end;

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

writeln('So phan tu chia het cho ',k,' la: ',dem1);

readln;

end.

Bài 1: 

uses crt;

var a:array[1..200]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] mod 5=0 then t:=t+a[i];

writeln('Tong cac so chia het cho 5 la: ',t);

readln;

end.

Bài 2: 

uses crt;

var st:string;

d,i:integer;

begin

clrscr;

write('Nhap xau:'); readln(st);

d:=length(st);

for i:=1 to d do 

  if st[i]=#32 then delete(st,i,1);

writeln(st);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,dem;

int main()

{

cin>>n;

dem=0;

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

{

cin>>x;

if (x%2==0) dem++;

}

cout<<dem;

return 0;

}

uses crt;

var a:array[1..100]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 then t:=t+a[i];

writeln(t);

readln;

end.

1 tháng 5 2023

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

s:longint;

i,n:integer;

Begin

Write('n = ');readln(n);

For i:=1 to n do

Begin

Write('Nhap so thu ',i);readln(a[i]);

If a[i] > 0 then s:=s+a[i];

End;

Write('Tong la ',s);

Readln

End.

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.