Những câu hỏi liên quan
Anh Nguyen
Xem chi tiết
Phía sau một cô gái
18 tháng 3 2023 lúc 19:37

N = int(input("Nhập số lượng phần tử của dãy N (>50): "))

while N <= 50:

         N = int(input("Nhập lại số lượng phần tử của dãy N (>50): "))

# Nhập vào dãy số 

danh_sach = []

for i in range(N):

         danh_sach.append(int(input("Nhập số thứ %d: " % (i+1))))

# In ra dãy số vừa nhập

print("Dãy số vừa nhập:")

for i in danh_sach:

         print(i, end=' ')

# Nhập vào số nguyên x

x = int(input("nNhập vào số nguyên x: "))

# In ra các số chia hết cho x 

print("Các số chia hết cho x là:")

for i in danh_sach:

         if i % x == 0:

                  print(i, end=' ')

Bình luận (0)
jaybk
Xem chi tiết
Anh Đức 8/8
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 4 2022 lúc 17:04

uses crt;

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

i,n,t:integer;

begin

clrscr;

readln(n);

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

t:=0;

for i:=1 to n do 

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

writeln(t);

readln;

end.

Bình luận (0)
Ái Cầm Trần
Xem chi tiết
Ngáo Ngơ Alice
Xem chi tiết
nguyễn an phát
11 tháng 4 2021 lúc 12:02

program timtich;

uses  crt;

var i,n:integer;

tich:longint;

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

begin

clrscr;

write('nhap so n:');readln(n);

for i:=1 to n do

begin

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

end;

for i:=1 to n do

write(a[i]:4);

tich:=1;

writeln;

for i:=1 to n do

if a[i] mod 2=0 then tich:=tich*a[i];

writeln('tich ca phan tu chan cua mang la:',tich);

readln;

end.

program timtong;

uses  crt;

var i,n:integer;

tong:longint;

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

begin

clrscr;

write('nhap so n:');readln(n);

for i:=1 to n do

begin

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

end;

for i:=1 to n do

write(a[i]:4);

tong:=0;

writeln;

for i:=1 to n do

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

writeln('tong cac phan tu chan cua mang la:',tong);

tong:=0;

writeln;

for i:=1 to n do

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

writeln('tong cac phan tu le cua mang la:',tong);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
11 tháng 4 2021 lúc 17:56

Bài 1: 

uses crt;

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

i,n,s:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

s:=1;

for i:=1 to n do 

  if a[i] mod 2=0 then s:=s*a[i];

writeln(s);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
11 tháng 4 2021 lúc 17:57

uses crt;

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

i,n,t1,t2:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

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

end;

t1:=0;

t2:=0;

for i:=1 to n do

begin

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

else t2:=t2+a[i];

end;

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

writeln('Tong cac so le la: ',t2);

readln;

end.

Bình luận (0)
Ha Cam
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 5 2021 lúc 11:57

uses crt;

var a:array[1..20]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;

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

 t:=t+a[i];

writeln('Tong cua day la: ',t);

for i:=1 to n do 

 if a[i]>50 then write(a[i]:4);

writeln;

for i:=1 to n do 

 if a[i]<30 then write(a[i]:4);

readln;

end.

Bình luận (0)
Phan Thu
Xem chi tiết
jaybk
Xem chi tiết
nguyễn văn A
4 tháng 5 2023 lúc 21:42

program tinh_tong_va_dem_so_x;

const
  MAX = 100;

var
  a: array[1..MAX] of integer;
  n, tong, x, dem, i: integer;

begin
  write('Nhap so phan tu cua mang: ');
  readln(n);
  for i := 1 to n do
  begin
    write('Nhap phan tu thu ', i, ': ');
    readln(a[i]);
  end;
  tong := 0;
  for i := 1 to n do
  begin
    tong := tong + a[i];
  end;
  writeln('Tong cac phan tu trong mang la: ', tong);
  write('Nhap gia tri x: ');
  readln(x);
  dem := 0;
  for i := 1 to n do
  begin
    if a[i] = x then
    begin
      dem := dem + 1;
    end;
  writeln('So lan xuat hien cua ', x, ' trong mang la: ', dem);
  readln;
end.

Bình luận (0)
Mai thị tố uyên
Xem chi tiết
Ngô Bá Hùng
1 tháng 5 2023 lúc 11:40

program PrintEvenOdd;

var
  num, even, odd, i: Integer;

begin
  even := 0;
  odd := 0;
  for i := 1 to 5 do
  begin
    writeln('Nhap so thu ', i, ': ');
    readln(num);
   
    if num mod 2 = 0 then
      even := even + 1 
    else
      odd := odd + 1;
  end;
  writeln('Tong chan: ', even);
  writeln('Tong le: ', odd);
end.

Bình luận (0)
Kiều Vũ Linh
1 tháng 5 2023 lúc 18:43

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

i:integer;

Begin

For i:=1 to 5 do

Begin

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

End;

Writeln('Cac so chan la ');

For i:=1 to 5 do

If a[i] mod 2 = 0 then write(a[i]:8);

Writeln;

Write('Cac so le la ');

For i:=1 to 5 do

If a[i] mod 2 <> 0 then write(a[i]:8);

Readln

End.

Bình luận (0)