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.

#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 && i%2!=0) dem++;

}

cout<<dem;

return 0;

return 0;

}

uses crt;

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

i,n,dem,t,t1,t2,t3,t4:integer;

begin

clrscr;

repeat

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

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

for i:=1 to n do 

  begin

repeat

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

until (0<a[i]) and (a[i]<=500);

end;

dem:=0;

for i:=1 to n do 

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

writeln('So phan tu co gia tri le la: ',dem);

t:=0;

for i:=1 to n do 

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

writeln('Tong cac phan tu co chi so chan la: ',t);

t1:=0;

for i:=1 to n do 

  if i mod 2=1 then t1:=t1+a[i];

writeln('Tong cac phan tu co chi so le la: ',t1);

t2:=0;

for i:=1 to n do 

  if (i mod 2=0) and (a[i] mod 2=0) then t2:=t2+a[i];

writeln('Tong cac phan tu chan co chi so chan la: ',t2);

t3:=0;

for i:=1 to n do 

  if (i mod 2=1) and (a[i] mod 2=1) then t3:=t3+a[i];

writeln('Tong cac phan tu co chi so le la: ',t3);

t4:=0;

for i:=1 to n do 

  t4:=t4+a[i];

writeln('Trung binh cong cac so trong day la: ',t4/n:4:2);

readln;

end.

24 tháng 2 2022

bạn tham khảo:

undefined

30 tháng 3 2023

A = [ ]

N = int(input("Nhập số phần tử của mảng: "))

for i in range(N):

     A.append(int(input("Nhập phần tử thứ %d: " % (i+1))))

count = 0

for i in range(N):

     if A[i] == 8:

          count += 1

print("Số lượng phần tử có giá trị bằng 8 là: ", count)

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

t=0;

dem=0;

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

if ((a[i]>0) and (i%2==1))

{

t+=a[i];

dem++;

}

cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0);

return 0;

}

24 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long a[6],i,t,t1;

int main()

{

t=0;

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

{

cin>>a[i];

if (a[i]%2==0) t=t+a[i];

}

t1=0;

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

if ((a[i]%2!=0) and (i%2==0)) t1=t1+a[i];

cout<<t<<endl;

cout<<t1;

return 0;

}

16 tháng 4 2023

program BaiToanMang;

var
  A: array[1..100] of integer;
  N, i, demChan, tongLeChia3: integer;

begin
  write('Nhap so phan tu cua mang: ');
  readln(N);
  writeln('Nhap cac phan tu cua mang: ');
  for i := 1 to N do
  begin
    write('a[', i, ']= ');
    readln(A[i]);
  end;
  tongLeChia3 := 0;
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 1) and (A[i] mod 3 = 0) then
    begin
      tongLeChia3 := tongLeChia3 + A[i];
    end;
  end;
  writeln('Tong cac so le chia het cho 3: ', tongLeChia3);
  demChan := 0;
  for i := 2 to N do
  begin
    if (A[i] mod 2 = 0) and (i mod 2 = 1) then
    begin
      demChan := demChan + 1;
    end;
  end;
  writeln('So phan tu chan o vi tri le: ', demChan);
  writeln('Cac so chan chia het cho 5: ');
  for i := 1 to N do
  begin
    if (A[i] mod 2 = 0) and (A[i] mod 5 = 0) then
    begin
      write(A[i], ' ');
    end;
  end;
end.

ko bt đúng ko ko dùng pascal nhiều

16 tháng 4 2023

b dùng pascal hay python V:

uses crt;

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

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

for i:=1 to n do 

  if a[i]=k then 

begin

writeln(i);

break;

end;

dem:=0;

for i:=1 to n do 

  if a[i]=k then inc(dem);

if dem>0 then writeln('Co ',dem,' phan tu bang ',k)

else writeln('Khong co phan tu nao bang ',k);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a[200],i,n,k;

int main()

{

cin>>n;

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

cin>>k;

kt=false;

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

if (a[i]==k)

{

cout<<i<<" ";

kt=true;

}

cout<<endl;

if (kt==false) cout<<"Khong co so k trong day"<<endl;

sort(a+1,a+n+1);

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}