Những câu hỏi liên quan
Vẹt Vẹt
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]);

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

writeln;

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 (1)
Hắc Lang
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 21:51

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

writeln(t);

readln;

end.

Bình luận (0)
ngô bá hiếu
Xem chi tiết
Kiều Vũ Linh
1 tháng 5 2023 lúc 18:38

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

s:longint;

i,n:integer;

Begin

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

For i:=1 to n do

Begin

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

If a[i] > 0 then s:=s+a[i];

End;

Write('Tong la ',s);

Readln

End.

Bình luận (0)
Nguyễn Ngọc Thiện Nhân
1 tháng 5 2023 lúc 10:16

Bình luận (3)
Trọng Nhân
Xem chi tiết
Kiều Vũ Linh
5 tháng 5 2022 lúc 13:10

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

i,n,s,s1:integer;

begin

write('Nhap so luong phan tu n = ');readln(n);

for i:=1 to n do

begin

write('Nhap phan tu thu ',i,' = ');readln(a[i]);

end;

writeln('Cac so vua nhap la ');

for i:=1 to n do

write(a[i],'   ');

for i:=1 to n do

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

for i:=1 to n do

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

writeln('Tong cac so nguyen duong trong day la ',s);

write('Tong cac so le la ',s1);

readln;

end.

Bình luận (2)
Uchiha Obito
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 5 2021 lúc 19:59

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

writeln(t);

readln;

end.

Bình luận (0)
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)
anhle
Xem chi tiết
Quỳnh
Xem chi tiết
Minh Lệ
29 tháng 4 2021 lúc 14:33

Program HOC24;

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

i,n,d: integer;

begin

write('Nhap N: ');

for i:=1 to n do

begin

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

end;

write('Day vua nhap la: '); 

for i:=1 to n do write(a[i],' '); writeln;

d:=0;

for i:=1 to n do if a[i]>0 then d:=d+1;

write('Co ',d,' so duong');

readln

end.

Bình luận (0)
Lê Thùy Ánh
Xem chi tiết
KhảTâm
14 tháng 5 2021 lúc 16:20

Bài 1:program sothuc;

uses crt;

var a:array[1..10] of real;s,i,j:real;

begin

s:=0;

for i:=1 to 10 do begin writeln('A[',i,']=');readln(a[i]); end;

for i:=1 to 10 do if a[i]<0 then

for j:=1 to 10 do

begin a[j]:=sqr(a[i]); s:=s+a[j]; end;

writeln('tong binh phuong cac so am la: ',s:2:2); readln;

end. (Khi nào mình kiểm tra chạy lại trên phần mềm rồi sửa lại nếu sai nhé)

Bài 2: 

program soduong;

uses crt;

var a:array[1..100] of integer;s,i,n:integer;

begin

clrscr;

writeln('nhap do dai cua day');readln(n);

for i:=1 to n do begin

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

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

writeln('tong so duong trong day la',s:2:0);readln

end.

Bài 3: các số dương mà là số lẻ là sao thế bạn????

Bình luận (0)
 Khách vãng lai đã xóa