K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

28 tháng 5 2020

Program HOC24;

const fi='inp.txt';

fo='output.txt';

var f: text;

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

i,n,d: integer;

procedure ip;

begin

assign(f,fi);

reset(f);

n:=0;

while not(eof(f)) do

begin

n:=n+1;

read(f,a[n]);

end;

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

d:=0;

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

write(f,d);

close(f);

end;

begin

ip;

out;

end.

const fi='input.txt';

fo='output.txt';

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 eoln(f1) do

begin

inc(n);

read(f1,a[n]);

end;

dem:=0;

for i:=1 to n do

if a[i]<0 then inc(dem);

writeln(f2,dem);

close(f1);

close(f2);

end.

const fi='input.txt';

fo='output.txt';

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 eof(f1) do 

begin

inc(n);

read(f1,a[n]);

end;

t:=0;

for i:=1 to n do t:=t+a[i];

write(f2,t);

close(f1);

close(f2);

end.

const fi='dataln.txt';

fo='dataout.txt';

var f1,f2:text;

x,i,t:integer;

begin

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

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

t:=0;

for i:=1 to 24 do 

begin

read(f1,x);

t:=t+x;

end;

writeln(f2,t);

close(f1);

close(f2);

end.

uses crt;

const fi='input.txt';

var f1:text;

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

    i,n:integer;

begin

clrscr;

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

n:=0;

while not eof(f1) do

  begin

     n:=n+1;

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

  end;

for i:=1 to n do

  writeln('Tong cua dong ',i,' la: ',a[i]+b[i]+c[i]:4:2);

for i:=1 to n do

  writeln('Trung binh cong cua dong ',i,' la: ',(a[i]+b[i]+c[i])/3:4:2);

close(f1);

readln;

end.

uses crt;

const fi='so.inp';

var f1:text;

a,b:integer;

begin

clrscr;

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

while not eof(f1) do 

 begin

readln(f1,a,b);

writeln((a+b)/2:4:2);

end;

close(f1);

readln;

end.

const fi='input.txt';
fo='output.txt';
var f1,f2:text;
n,i,dem:integer;
a:array[1..100]of integer;
{------------------------chuong-trinh-con-1----------------------------}
procedure docfile;
begin
assign(f1,fi); reset(f1);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
close(f1);
end;
{------------------------chuong-trinh-con-2----------------------------}
procedure xuatfile;
begin
assign(f2,fo); rewrite(f2);
dem:=0;
for i:=1 to n do
if a[i] mod 5=0 then inc(dem);
writeln(f2,dem);
close(f2);
end;
{-------------------------chuong-trinh-chinh-------------------------}
begin
docfile;
xuatfile;
end.

Bài 1:

const fi='input.txt';

fo='output.txt';

var f1,f2:text;

a,b,s:integer;

begin

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

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

readln(f1,a,b);

s:=a*b;

writeln(f2,s);

close(f1);

close(f2);

end.

Bài 2:

const fi='dulieu.txt';

fo='ketqua.txt';

var f1,f2:text;

a,b:integer;

begin

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

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

readln(f1,a,b);

if a>b then writeln(f2,a)

else if b>a then writeln(f2,b)

else writeln(f2,' khong co so lon nhat trong hai so');

close(f1);

close(f2);

end.