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.

15 tháng 5 2020

Program HOC24;

const fi='Data.txt';

fo='Result.txt';

var f: text;

a,b: integer;

dt,cv: longint;

dc: real;

procedure ip;

begin

assign(f,fi);

reset(f);

readln(f,a);

readln(f,b);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

dt:=a*b;

cv:=(a+b)*2;

dc:=sqrt((a*a)+(b*b));

writeln(f,'Chu vi hinh chu nhat la : ',cv);

writeln(f,'Dien tich cua hinh chu nhat la : ',dt);

write(f,'Chieu dai cua duong cheo la : ',dc:1:2);

close(f);

end;

begin

ip;

out;

end.

const fi='data.txt';

fo='ketqua.txt';

var f1,f2:text;

a,b,h:integer;

begin

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

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

readln(f1,a,b,h);

writeln(f2,0.5*h*(a+b):4:2);

close(f1);

close(f2);

end.

uses crt;

const fi='baitap.txt';

var f1:text;

a,b:integer;

begin

clrscr;

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

readln(f1,a,b);

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

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

close(f1);

readln;

end.

uses crt;

const fi='baitap.txt';

var f1:text;

a,b:integer;

begin

clrscr;

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

readln(f1,a,b);

writeln('Chu vi hinh chu nhat la: ',(a+b)*2);

close(f1);

readln;

end.

uses crt;

const fi='dulieu.dat';

var f1:text;

a,b,p,s: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(a[n],b[n]);

end;

for i:=1 to n do 

  begin

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

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

end;

for i:=1 to n do 

  writeln(p[i]:4:2,' ',s[i]:4:2);

close(f1);

readln;

end.

uses crt;

const fi='canh_ht.int';

var f1:text;

a,b,h,c,d:integer;

begin

clrscr;

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

readln(f1,a,b,c,d,h);

writeln(a+b+c+d);

writeln(1/2*h*(a+b):4:2);

close(f1);

readln;

end.

uses crt;

const fi='x.inp';

var f1:text;

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

i,n:integer;

begin

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

n:=0;

while not eof(f1) do 

begin

n:=n+1;

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

end;

for i:=1 to n do 

  begin

writeln('Chu vi dong ',i,' la: ',(a[i]+b[i])*2);

writeln('Dien tich dong ',i,' la: ',a[i]*b[i]);

end;

close(f1);

readln;

end.

uses crt;

const fi='hcn.dat';

fo='chuvi.out';

var f1,f2:text;

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

n,i,j:integer;

begin

clrscr;

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

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

n:=0;

while not eof(f1) do

begin

n:=n+1;

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

end;

for i:=1 to n do

writeln(a[i]*b[i]);

for i:=1 to n do 

  writeln(f2,2*(a[i]+b[i]));

close(f1);

close(f2);

readln;

end.

10 tháng 5 2023

with open('DULIEU.INP', 'r') as input_file:

         p, q = map(int, input_file.readline().strip().split())

chu_vi = 2 * (p + q)

dien_tich = p * q

with open('KETQUA.OUT', 'w') as output_file:

         output_file.write(f'Chu vi hinh chu nhat la: {chu_vi}\n')

         output_file.write(f'Dien tich hinh chu nhat la: {dien_tich}\n')