Những câu hỏi liên quan
Vũ văn huy
Xem chi tiết
Nguyễn Lê Phước Thịnh
9 tháng 4 2022 lúc 10:04

uses crt;

const fi='mang.inp'

var f1:text;

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

i,n:integer;

begin

clrscr;

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

n:=0;

while not eof(f1) do 

begin

n:=n+1;

read(f1,a[i]);

end;

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

close(f1);

readln;

end.

Bình luận (0)
Quỳnh Phan
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 4 2021 lúc 20:18

const fi='bt1.inp'

fo='bt1.out'

var f1,f2:text;

a,b:integer;

begin

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

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

readln(f1,a,b);

writeln(f2,'Chu vi la: ',(a+b)*2);

writeln(f2,'Dien tich la: ',a*b);

close(f1);

close(f2);

end.

Bình luận (0)
An Hạ
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 3 2021 lúc 20:25

uses crt;

const fi='data.txt'

var f1:text;

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

n,i:integer;

begin

clrscr;

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

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

for i:=1 to n do 

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

close(f1);

readln;

end.

Bình luận (0)
Louis Kai
Xem chi tiết
Nguyen Duc Anh
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 5 2021 lúc 13:42

const fi='hcn.txt'

fo='ketqua.txt'

var f1,f2:text;

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

n:integer;

cv,dt:real;

begin

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

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

n:=0;

while not eof(f1) do

  begin

inc(n);

readln(f1,a[n],b[n]);

end;

for i:=1 to n do 

  begin

cv:=(a[i]+b[i])/2;

dt:=a[i]*b[i];

writeln(f2,cv:4:2,' ',dt:4:2);

end;

close(f1);

close(f2);

end.

Bình luận (0)
Phan Thị Thùy Ngân
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 5 2021 lúc 22:29

Câu 2: 

uses crt;

var a,b:integer;

{-----------------chuong-trinh-con-------------------}

function ucln(x,y:integer):integer;

var i,uc:integer;

begin

if x<y then 

begin

uc:=1;

for i:=1 to x do 

  if (x mod i=0) and (y mod i=0) then  

begin

if uc<i then uc:=i;

end;

end

else begin

uc:=1;

for i:=1 to y do 

  if (x mod i=0) and (y mod i=0) then  

begin

if uc<i then uc:=i;

end;

end;

ucln:=uc;

end;

{--------------------------chuong-trinh-chinh------------------------}

begin

clrscr;

write('Nhap a='); readln(a);

write('Nhap b='); readln(b);

writeln(a,'/',b,'=',a div ucln(a,b),'/',b div ucln(a,b));

readln;

end.

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

Câu 1: 

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.

Bình luận (0)
Thùy Linh Ngô
Xem chi tiết
Nguyễn Lê Phước Thịnh
30 tháng 12 2021 lúc 23:29

1:

uses crt;

const fi='songuyen.doc'

var i:integer;

f1:text;

begin

clrscr;

assign(f1,fi); rewrite(f1);

for i:=1 to 10 do write(f1,i:4);

close(f1);

readln;

end.

Bình luận (0)
Đặng Công
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 5 2021 lúc 20:31

uses crt;

const fi='dl.txt'

fo='soam.txt'

var f1,f2:text;

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

i,n:integer;

begin

clrscr;

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;

for i:=1 to n do 

begin

  if a[i]>0 then writeln('Can bac hai cua ',a[i],' la: ',sqrt(a[i]):4:2)

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

end;

close(f1);

close(f2);

readln;

end.

Bình luận (0)
Đặng Công
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 5 2021 lúc 20:32

uses crt;

const fi='dl.txt'

fo='soam.txt'

var f1,f2:text;

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

i,n:integer;

begin

clrscr;

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;

for i:=1 to n do 

begin

  if a[i]>0 then writeln('Can bac hai cua ',a[i],' la: ',sqrt(a[i]):4:2)

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

end;

close(f1);

close(f2);

readln;

end.

Bình luận (0)