Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
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.

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.

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.

Nhảy chân sáo mà từ từ đ...
Xem chi tiết
Nguyễn Lê Phước Thịnh
15 tháng 3 2022 lúc 20:38

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

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

if (a[i]%2==0) cout<<a[i]<<" ";

cout<<endl;

t=0;

dem=0;

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

if (a[i]%2==0)

{

t=t+a[i];

dem++;

}

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

t1=0;

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

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

cout<<t1;

return 0;

}

Nguyễn Ally
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 8 2021 lúc 0:22

uses crt;

var n,t1:integer;

s:real;

begin

clrscr;

t1:=0;

s:=1;

repeat

readln\(\left(n\right)\);

if n mod 2=0 then t1:=t1+n

else s:=s*n;

until n=0;

writeln\(\left(t1\right)\);

writeln\(\left(s:4:2\right)\);

readln;

end.

Vân anh
Xem chi tiết
Phía sau một cô gái
22 tháng 4 2023 lúc 20:18

program TongChanLe;

var

     n,i, chans, les: integer; a: array[1..100] of integer;

begin

     chans := 0;

     les := 0;

     write('Nhap n: ');

     readln(n);

     for i:=1 to n do

     begin

          write('Nhap so thu ', i, ': ');

          readln(a[i]);

          if a[i] mod 2 = 0 then

               chans := chans + a[i]

          else

               les := les + a[i];

     end;

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

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

     readln;

end.

Mai Phương Lê
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

Bài 1: 

uses crt;

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

i,n: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 

  if a[i] mod 2<>0 then write(a[i]:4);

readln;

end.

Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

Bài 2: 

uses crt;

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

i,n: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

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

readln;

end.

Nguyễn Lê Phước Thịnh
5 tháng 5 2021 lúc 13:14

Bài 3: 

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] mod 2<>0 then t:=t+a[i];

writeln(t);

readln;

end.

Quân Đoàn Long Tường
Xem chi tiết
Thành Phạm
26 tháng 4 2023 lúc 10:20

Python:
n = input("Nhập dãy số nguyên: ").split()
n = [int(i) for i in n]

so_le = [i for i in n if i % 2 != 0]
tong = sum(n)

print("Các số lẻ trong dãy là: ", so_le)
print("Tổng các số trong dãy là: ", tong)

Pascal:

program tongvasole;

const
  MAX_SIZE = 1000;

var
  numbers: array[1..MAX_SIZE] of Integer;
  count, i: Integer;
  total: Integer;
begin
  Write('Nhập số lượng phần tử trong dãy: ');
  ReadLn(count);
  for i := 1 to count do
  begin
    Write('Nhập phần tử thứ ', i, ': ');
    ReadLn(numbers[i]);
  end;

  Write('Các số lẻ trong dãy là: ');
  total := 0;
  for i := 1 to count do
  begin
    if numbers[i] mod 2 <> 0 then
      Write(numbers[i], ' ');
    total := total + numbers[i];
  end;
  WriteLn;

  WriteLn('Tổng các số trong dãy là: ', total);
end.

AETC丶NhấtㅤGG
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 5 2022 lúc 23:30

1:

#include <bits/stdc++.h>

using namespace std;

long long n=10, a[10],i,nn;

int main()

{

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

nn=a[1];

for (i=2; i<=n; i++) nn=min(nn,a[i]);

cout<<nn;

return 0;

}

Đặng Đức Nam
Xem chi tiết
Kiều Vũ Linh
20 tháng 4 2023 lúc 8:56

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

i,n:integer;

sc,sl:longint;

Begin

Write('Nhap so luong so cua day ');readln(n);

For i:=1 to n do

Begin

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

End;

Write('Tong cac so chan la ');

For i:=1 to n do

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

Writeln(sc);

Write('Tong cac so le la ');

For i:=1 to n do

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

Write(sl);

Readln

End.

Sói Channel
Xem chi tiết
Phía sau một cô gái
18 tháng 2 2023 lúc 15:07

n = int(input('Nhập n ( n < 150): '))

if n >= 150:

     print('n phải nhỏ hơn 150')

else:

     arr = [ ]

     total = 0

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

     for i in range(n):

          arr.append(int(input('Nhập phần tử thứ ' + str(i+1) + ': ')))

     # In dãy vừa nhập

     print('Dãy vừa nhập là: ', end='')

     for i in range(n):

          print(arr[i], end=' ')

     # Tính tổng các phần tử lẻ

     for i in range(n):

          if arr[i] % 2 != 0:

               total += arr[i]

     print('\nTổng các phần tử lẻ là:', total)