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
Tiên Tiên
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 5 2021 lúc 22:22

const fi='songuyen.inp'

fo='tong.out'

var f1,f2:text;

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

i,n,t:integer;

begin

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

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

n:=0;

while not eoln(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

t:=0;

for i:=1 to n do 

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

writeln(f2,t);

close(f1);

close(f2);

end.

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.

Hồ Thị Huyền Trang
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:17

const fi='songuyen.inp'

fo='tong.out'

var f1,f2:text;

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

n,i,dem:integer;

begin

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

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

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then inc(dem);

writeln(f2,dem);

close(f1);

close(f2);

end.

Dương Hữu Thành
Xem chi tiết
Phương Hoài
Xem chi tiết
Quyên Mai
17 tháng 3 2023 lúc 21:19

mình cũng cần ạ

Minh Lệ
17 tháng 3 2023 lúc 23:04

a)

Input: Số nguyên dương N, dãy số a1,a2,a3,...,an

Output: Tổng các số chẵn nhỏ hơn hoặc bằng N

b)

Program HOC24;

var i,n: integer;

t: longint;

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

f1,f2: text;

const fi='SONGUYEN.TXT'

fo='SOCHAN.TXT'

begin

assign(f1,fi);

assign(f2,fo);

reset(f1);

rewrite(f2);

readln(f1,n);

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

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

begin

write(f2,a[i],' ');

t:=t+a[i];

end;

writeln(f2);

write(f2,t);

close(f1); close(f2);

end.

Quỳnh Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 5 2021 lúc 20:33

const fi='bai1.inp'

fo='bai1.out'

var f1,f2:text;

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

n,i,t,dem:integer;

begin

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

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

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t:=0;

dem:=0;

for i:=1 to n do 

  begin

if a[i] mod 2<>0 then t:=t+a[i]

else inc(dem);

end;

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

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

close(f1);

close(f2);

end.

Phạm Công Ngọc Quốc
Xem chi tiết
Phạm Công Ngọc Quốc
26 tháng 4 2022 lúc 21:23

giúp mik với mai thi mik thi rồi🙏🙏

 

Thế Thôi
26 tháng 4 2022 lúc 22:48

program b1;
uses crt;
var i: integer; a:array[1..100] of integer; s:longint;
begin
clrscr;
for i:=1 to 10 do
begin
write('a[',i,']='); readln(a[i]);
end;
writeln('cac phan tu chan la:');
s:=0;
for i:=1 to 10 do if a[i] mod 2=0 then writeln(a[i],' ');
write('Tong cac phan tu le la:');
for i:=1 to 10 do if a[i] mod 2<>0 then s:=s+a[i]; write(s);
readln;
end.

Tham khảo!

Trang
Xem chi tiết
Nguyễn Lê Phước Thịnh
10 tháng 5 2022 lúc 23:13

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

cin>>n;

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

for (i=1; i<=n; i++) cout<<a[i]<<" ";

cout<<endl;

t=0;

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

cout<<t;

return 0;

}

Hoangf Thu
Xem chi tiết