Những câu hỏi liên quan
Lê Tuấn Anh
Xem chi tiết
Minh Lệ
23 tháng 4 2020 lúc 11:18

Câu 1:

Program hotrotinhoc_hoc24;

const fi='mang.txt';

fo='tong.txt';

var f: text;

a,b,c,d: integer;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,a,b,c,d);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

write(f,a+b+c+d);

close(f);

end;

begin

ip;

out;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
23 tháng 4 2020 lúc 11:29

Câu 1:

const fi='mang.txt';
fo='tong.txt';
var f1,f2:text;
dem,i,t:integer;
a:array[1..4]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eoln(f1) do
begin
inc(dem);
read(f1,a[dem]);
end;
t:=0;
for i:=1 to dem do
t:=t+a[i];
writeln(f2,t);
close(f1);
close(f2);
end.

Câu 2:

const fi='ptb2.txt';
fo='ketqua.txt';
var f1,f2:text;
a,b,c,delta,x1,x2:real;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,a,b,c);
delta:=sqr(b)-4*a*c;
if delta>0 then
begin
x1:=(-b-sqrt(delta))/2*a;
writeln(f2,'x1=',x1:4:2);
x2:=(-b+sqrt(delta))/2*a;
writeln(f2,'x2=',x2:4:2);
end
else if delta=0 then writeln(f2,'x1=x2=',-b/(2*a):4:2)
else writeln(f2,'phuong trinh vo nghiem');
close(f1);
close(f2);
end.

Câu 5:

const fi='dulieu.dat';
fo='tb.dat';
var f1,f2:text;
a:array[1..4]of integer;
dem,i:integer;
tb:real;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
dem:=0;
while not eof(f1) do
begin
inc(dem);
read(f1,a[dem]);
end;
tb:=0;
for i:=1 to dem do
tb:=tb+a[i];
writeln(f2,tb/dem:4:2);
close(f1);
close(f2);
end.

 

Bình luận (0)
Minh Lệ
23 tháng 4 2020 lúc 11:30

Câu 2:

Program hotrotinhoc_hoc24;

const fi='ptb2.txt';

fo='ketqua.txt';

var f: text ;

a,b,c,denta: real;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,a,b,c);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

denta:=sqr(b)-4*(a)*(c);

if denta<0 then write(f,'Phuong trinh vo nghiem');

if denta=0 then write(f,'Phuong trinh co nghiem kep ,gia tri x=',-(b/2*a));

if denta>0 then write(f,'Phuong trinh co hai nghiem phan biet,gia tri x1=',(-(b)+sqr(denta))/(2*a):1:2,' gia tri x2=',(-(b)-sqr(denta))/(2*a):1:2);

close(f);

end;

begin

ip;

out;

end.

Bình luận (0)
APOK FF
Xem chi tiết
Tuong Le
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 12 2020 lúc 22:41

const fo='int.txt'

fo='out.txt'

var f1,f2:text;

m,n:integer;

begin

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

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

readln(f1,m);

readln(f1,n);

writeln(f2,m+n);

close(f1);

close(f2);

end.

Bình luận (0)
Yến Chi Phan Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
8 tháng 3 2022 lúc 6:55

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.

Bình luận (0)
huynh chinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 3 2022 lúc 22:48

#include <bits/stdc++.h>

using namespace std;

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

int main()

{

freopen("avg.inp","r",stdin);

freopen("avg.out","w",stdout);

cin>>n;

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

t=0;

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

cout<<fixed<<setprecision(1)<<(t*1.0)/(n*1.0);

return 0;

}

Bình luận (0)
Mộng Chúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 10:03

#include <bits/stdc++.h>

using namespace std;

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

bool kt;

int main()

{

freopen("nguyento.inp","r",stdin);

freopen("nguyento.out","w",stdout);

cin>>n;

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

for (i=1; i<=n; i++)

if (a[i]>1) 

{

kt=true;

for (j=2; j*j<=a[i]; j++)

if (a[i]%j==0) kt=false;

if (kt==true) cout<<a[i]<<" ";

}

return 0;

}

Bình luận (0)
le hong trinh
Xem chi tiết
CHU ANH TUẤN
Xem chi tiết
Đặng Phạm Thành Nhật
Xem chi tiết
Đặng Phạm Thành Nhật
28 tháng 9 2021 lúc 16:27

mình ghi dư cái số 4 bên phần BAI7.INP nha mn

 

Bình luận (1)