Những câu hỏi liên quan
Meo Meo
Xem chi tiết
Giagg
Xem chi tiết
Nguyễn Lê Phước Thịnh
5 tháng 3 2021 lúc 21:42

const fi='dulieu.dat'

fo='ketqua.dat'

var f1,f2:text;

n,i,s:integer;

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

begin

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

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

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

s:=0;

for i:=1 to n do 

  s:=s+a[i];

writeln(f2,s);

close(f1);

close(f2);

end.

Bình luận (0)
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)
Exo Aeri
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 1 2022 lúc 13:12

#include <bits/stdc++.h>

using namespace std;

long long a[10],b[10],i,j;

int main()

{

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

freopen("output.txt","w",stdout);

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

for (j=1; j<=10; j++) cin>>b[j];

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

cout<<a[i]+b[i]<<" ";

return 0;

}

Bình luận (0)
Nguyễn Hoàng Thiên Lam
Xem chi tiết
Nguyễn Lê Phước Thịnh
28 tháng 1 2022 lúc 22:41

#include <bits/stdc++.h>

using namespace std;

long long a,b;

int main()

{

freopen("dulieu.txt","r",stdout);

freopen("ketqua.txt","w",stdout);

cin>>a>>b;

cout<<a+b;

return 0;

}

Bình luận (0)
Hân Cao
Xem chi tiết
Nguyễn Lê Phước Thịnh
12 tháng 5 2022 lúc 7:46

uses crt;

const fi='dulieu.txt'

var f1:text;

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

t:real;

i,n:integer;

begin

clrscr;

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

readln(f1,n);

for i:=1 to n do readln(f1,a[i]);

t:=0;

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

writeln(t);

close(f1);

readln;

end.

Bình luận (0)
Sự tâm
Xem chi tiết
Trang
Xem chi tiết
Pham Trong Bach
Xem chi tiết
Cao Minh Tâm
6 tháng 6 2017 lúc 9:38

Bình luận (0)