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.

6 tháng 4 2023

# Dãy số thứ nhất

list1 = list(map(int, input("Nhập dãy số thứ nhất, cách nhau bằng khoảng trắng: ").split()))

so_chan1 = 0

so_le1 = 0

for num in list1:

     if num % 2 == 0:

          so_chan1 += 1

     else:

          so_le1 += 1

print("Trong dãy số thứ nhất có", so_chan1, "số chẵn và", so_le1, "số lẻ.")

# Dãy số thứ hai

list2 = list(map(int, input("Nhập dãy số thứ hai, cách nhau bằng khoảng trắng: ").split()))

so_chan2 = 0

so_le2 = 0

for num in list2:

     if num % 2 == 0:

          so_chan2 += 1

     else:

          so_le2 += 1

print("Trong dãy số thứ hai có", so_chan2, "số chẵn và", so_le2, "số lẻ.")

23 tháng 3 2023

program Tim_So_Le_Chia_Het_Cho_3;

uses crt;

var

     n, i, count: integer;

begin

     clrscr;

     write('Nhap vao mot so nguyen duong n: ');

     readln(n);

     writeln('Cac so le chia het cho 3 nho hon ', n, ' la: ');

     count := 0;

     for i := 1 to n do

     begin

          if (i mod 2 = 1) and (i mod 3 = 0) then

          begin

               writeln(i);

               count := count + 1;

          end;

     end;

     writeln('Co tat ca ', count, ' so le chia het cho 3');

     readln;

end.

5 tháng 5 2023

Bài 5:

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

i,n,max:integer;

sc, sl:longint;

Begin

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

For i:=1 to n do

Begin

Write('Nhap so thu ',i,' = ');rreadlna[i]);

If a[i] mod 2 = 0 then sc:=sc+b[i];

If a[i] mod 2 <> 0 then sl:=sl+a[i];

End;

max:=a[1];

For i:=2 to n do

If a[i] > max then max:=a[i];

Writeln('Tong cac so chan la ',sc);

Writeln('Tong cac so le la ',sl);

write('So lon nhat la ',max);

Readln

End.

5 tháng 5 2023

Xin cảm ơnloading...  

Câu 2: 

a) Mô tả thuật toán

-Bước 1: Nhập n và nhập dãy số

-Bước 2: dem←0; i←1; t←0;

-Bước 3: Nếu a[i] mod 2=0 thì dem←dem+1 và t←t+a[i];

-Bước 4: i←i+1;

-Bước 5: Nếu i<=n thì quay lại bước 3

-Bước 6: Xuất t và dem

-Bước 7: Kết thúc

Câu 2: 

b) uses crt;

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

i,n,t,dem:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

t:=0;

dem:=0;

for i:=1 to n do 

 if a[i] mod 2=0 then 

begin

t:=t+a[i];

inc(dem);

end;

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

writeln('Tong cac so chan la: ',t);

readln;

end.

uses crt;

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

i,n,dem:integer;

begin

clrscr;

readln(n);

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

dem:=0;

for i:=1 to n do if a[i] mod 2=0 then inc(dem);

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

writeln('so so le la: ',n-dem);

readln;

end.

3 tháng 5 2023

Program HOC24;

var i,n: integer;

t: longint;

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

begin

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

for i:=1 to n do

begin

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

end;

t:=0;

for i:=1 to n do if a[i] mod 2=0 then t:=t+a[i];

write('Tong cac so chan la: ',t);

readln

end.

19 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long n;

int main()

{

cin>>n;

if (n%2==0) cout<<"Chan";

else cout<<"Le";

return 0;

}