Những câu hỏi liên quan
Nguyễn Mỹ
Xem chi tiết
nguyễn an phát
5 tháng 4 2021 lúc 18:23

Bài 1:

program in_phan_tu;

uses crt;

var n,i:longint;

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

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]:3);

readln;

end.

Bài 2:

program tong_phan_tu;

uses crt;

var n,i,tong:longint;

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

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;

tong:=0;

for i:=1 to n do

tong:=tong+a[i];

writeln('tong cua day la:');

readln;

end.

Bài 3:

program tong_phan_tu_chan;

uses crt;

var n,i,tong:longint;

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

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;

tong:=0;

for i:=1 to n do

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

writeln('tong cua day la:');

readln;

end.

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

Câu 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 

  write(a[i]:4);

readln;

end.

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

Câu 2: 

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 

 t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (0)
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)
Hoangf Thu
Xem chi tiết
Hải Phong
Xem chi tiết
Hải Phong
10 tháng 12 2021 lúc 11:13

huhu giúp với ạ cần gấp lắm

Bình luận (0)
Nguyễn Lê Phước Thịnh
10 tháng 12 2021 lúc 23:14

1:

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

t=t+x;

}

cout<<t;

return 0;

}

Bình luận (0)
Hải Hà
Xem chi tiết
Minh Lệ
6 tháng 4 2023 lúc 22:49

Bài 1:

Program HOC24;

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

i,n,d: integer;

begin

write('Nhap so phan tu: '); readln(n);

for i:=1 to n do 

begin

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

end;

for i:=1 to n do if (a[i]<0) and (a[i] mod 2=0) then d:=d+1;

write('Co ',d,' so nguyen am chan trong day so');

readln

end.

Bình luận (0)
Minh Lệ
6 tháng 4 2023 lúc 22:54

Bài 2:

Program HOC24;

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

i,n: integer;

t: longint;

begin

write('Nhap so phan tu: '); 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 5=0 then t:=t+a[i];

write(Tong la: ',t);

readln

end.

Bình luận (0)
Minh Lệ
6 tháng 4 2023 lúc 22:55

Bài 3:

Program HOC24;

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

i,n: integer;

t: longint;

begin

write('Nhap so phan tu: '); readln(n);

for i:=1 to n do 

begin

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

end;

t:=1;

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

write('Tich la: ',t);

readln

end.

Bình luận (0)
Quỳnh Như
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 5 2022 lúc 23:21

uses crt;

const fi='songuyen.inp'

fo='songuyen2.out'

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

i,n,t1:integer;

f1,f2:text;

begin

clrscr;

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

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

t1:=0;

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

writeln(t1);

writeln(f2,t1);

for i:=1 to n do 

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

close(f1);

close(f2);

readln;

end.

Bình luận (0)
Phạm Đức
Xem chi tiết
Nguyễn Lê Phước Thịnh
11 tháng 3 2022 lúc 9:47

uses crt;

const fi='baitap.txt'

var f1:text;

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

i:integer;

begin

clrscr;

assign(f1,fi); reset(f1);

for i:=1 to 5 do readln(f1,a[i]);

for i:=1 to 5 do write(a[i]:4);

close(f1);

readln;

end.

Bình luận (0)
ngỷyvjhy
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 12 2021 lúc 21:56

b: #include <bits/stdc++.h>

using namespace std;

long long b[1000],i,n;

int main()

{

cin>>n;

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

cin>>b[i];

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

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

cout<<b[i]<<" ";

return 0;

}

Bình luận (0)
Dương Hữu Thành
Xem chi tiết
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.

Bình luận (0)