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

const fi='songuyen.txt'

fo='kluan.txt'

var f1,f2:text;

n:integer;

begin

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

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

readln(f1,n);

if n mod 2=0 then writeln(f2,'La so chan')

else writeln(f2,'La so le');

close(f1);

close(f2);

end.

Minh Trí Đoàn
Xem chi tiết
Phía sau một cô gái
18 tháng 2 2023 lúc 14:54

with open('songuyen.txt', 'r') as f:

     with open('ketqua.txt', 'w') as g:

          for line in f:

               numbers = line.split()

               for number in numbers:

                    if int(number) % 2 == 0:

                         g.write(number + '\n')

      
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.

Lê Đức Tài
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 3 2022 lúc 14:06

#include <bits/stdc++.h>

using namespace std;

long long i,a[100],n;

int main()

{

freopen("songuyen.txt","r",stdin);

n=20;

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

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

return 0;

}

Đàm Duy Nam
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 4 2020 lúc 20:32

const fi='songuyen.txt';
fo='sochan.txt';
var f1,f2:text;
a:array[1..100]of integer;
i,dem:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eof(f1) do
begin
inc(dem);
readln(f1,a[dem]);
end;
for i:=1 to dem do
if a[i] mod 2=0 then write(f2,a[i]:4);
close(f1);
close(f2);
end.

Hà Như Trang
Xem chi tiết
Minh Lệ
17 tháng 5 2020 lúc 14:51

Program HOC24;

const fi='SONGUYEN.TXT';

fo='KETQUA.TXT';

var n,i,d:integer;

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

function nt(x: integer): boolean;

var j: integer;

begin

nt:=true;

if (x=2) or (x=3) then exit;

nt:=false;

if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;

j:=5;

while j<=trunc(sqrt(x)) do

begin

if (x mod j=0) or (x mod (j+2)=0) then exit;

j:=j+6;

end;

nt:=true;

end;

procedure ip;

begin

assign(f,fi);

reset(f);

readln(f,n);

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

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

d:=0;

for i:=1 to n do

if nt(a[i]) then inc(d);

write(f,d);

close(f);

end;

begin

ip;

out;

end.

Trần Thị Quỳnh Như
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 6 2020 lúc 12:36

uses crt;
const fi='data.txt';
fo='songuyen.txt';
var f1,f2:text;
a:array[1..100]of integer;
m,i,dem,k:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,m);
for i:=1 to m do
read(f1,a[i]);
for i:=1 to m do
if a[i]>0 then write(f2,a[i]:4);
writeln(f2);
write('Nhap so k='); readln(k);
dem:=0;
for i:=1 to m do
if a[i] mod k=0 then inc(dem);
writeln(f2,'So cac phan tu la boi cua ',k,' la: ',dem);
close(f1);
close(f2);
readln;
end.

Bắc Lee
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 4 2021 lúc 21:35

uses crt;

const fi='songuyen.txt'

var f1:text;

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

i,n,t:integer;

begin

clrscr;

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

n:=0;

while not eof(f1) do 

  begin

inc(n);

read(f1,a[n]);

end;

t:=0;

for i:=1 to n do 

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

writeln(t);

close(f1);

readln;

end.

Trần Gia Linh
Xem chi tiết
Trần Gia Linh
5 tháng 4 2021 lúc 9:01

ai giup e voi dc k ah:( đang thi ạ

 

Trần Gia Linh
5 tháng 4 2021 lúc 9:02

alo mng ơi=(((

 

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

const fi='songuyen.txt'

fo='soduong.out'

var f1,f2:text;

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

i,n:integer;

begin

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

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

n:=0;

while not eof(f1) do 

  begin

inc(n);

read(f1,a[n]);

end;

for i:=1 to n do 

  if a[i]>0 then write(f2,a[i]:4);

close(f1);

close(f2);

end.