M.n giải giúp em bài này với ạ: Đọc dữ liệu gồm 3 số thực từ tệp VB.TXT sau đó tính tổng, tích của 3 số thực trên ghi vào tệp KQ.TXT
#em cảm ơn
Cho tệp BT.TXT chứa 3 số nguyên liên tiếp trên 1 dòng. Viết chương trình đọc dữ liệu từ tệp BT.TXT, tính tổng các số trên cùng 1 dòng; ghi tổng của các dòng vào tệp KQ.txt
HƯỚNG DẪN
Các bước thực hiện bài toán ?
1. Gắn tệp BT.TXT, KQ.TXT vào các biến tệp
2. Mở tệp BT.TXT để đọc và mở tệp KQ.TXT để ghi
3. Nếu chưa cuối tệp BT.TXT thì thực hiện
3.1. Đọc dữ liệu từ tệp gắn vào biến x, y, z
3.2. tß x+y+z
3.3. Ghi t vào tệp KQ.TXT trên 1 dòng
4. Đóng các tệp
Program hotrotinhoc_hoc24;
const fi='BT.TXT';
fo='KQ.TXT';
var f: text;
x,y,z: integer;
t: longint;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,x,y,z);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
t:=x+y+z;
write(f,t);
close(f);
end;
begin
ip;
out;
end.
Cho 50 số nguyên được ghi trong tệp 'NUMBER.TXT' (dữ liệu được ghi trên một dòng). Hãy viết chương trình đọc các số nguyên chẵn trong 50 số nguyên đó và ghi ra tệp 'KQ.TXT' GIÚP E VỚI Ạ. E ĐANG CẦN GẤPPPPP
Cho tệp ăn.txt chứa dãy các số nguyên liên tiếp viết cách nhau 1 dấu cách .viết CT đọc dữ liệu từ tệp txt tính tổng các số chẵn và tổng các số lẻ ghi kết quả vào tập kq.txt trên 2 dòng
Đọc dữ liệu gồm 3 số thực từ tệp BT.txt sau đó tính trung bình cộng của 3 số trên và ghi vào tệp KT.txt
const fi='bt.txt';
fo='kt.txt';
var f1,f2:text;
a,b,c,tbc:real;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,a,b,c);
tbc:=(a+b+c)/3;
writeln(f2,tbc:4:2);
close(f1);
close(f2);
end.
Đọc dữ liệu từ tệp hoặc mảng, xuất dữ liệu. Sử dụng chương trình con tìm min hoặc max. Sau đó ghi kết quả vào tệp hoặc mảng. Giúp em mn ạ
uses crt;
var a:array[1..100]of integer;
i,n,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('So lon nhat la: ',max);
writeln('So nho nhat la: ',min);
readln;
end.
Cho tệp số thực txt chứa các cặp số mỗi cặp số lưu trên 1 dòng. Tạo tệp diện tích tính và ghi dữ liệu vào tệp diện tích ứng với mỗi cặp. 1, Hình bình hành 2, Hình tháng 3, Hình tâm giác
Viết chương trình và sử dụng chương trình con đọc dữ liệu từ tệp input.txt chứa dãy số nguyên trên một dòng. Các số cách nhau một khoảng trắng
Tính tổng dãy số trong tập input.txt rồi ghi kết quả tổng này vào tập output.txt
Giúp em với ạ. Em cảm ơn
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.
Cho tệp văn bản DAYSO.INP có cấu trúc:
+ Dòng 1: Ghi số nguyên dương N (0<N<=100)
+ Dòng 2: Ghi dãy gồm n số nguyên Ai (-30000<=Ai<=30000).
Yêu cầu: Viết chương trình đọc dữ liệu từ tệp trên và thực hiện các công việc sau:
a) Tính tổng các số ở dòng 2, ghi kết quả vào tệp TONG.OUT theo cấu trúc:
+ Dòng 1: Ghi số nguyên S là tổng tìm được
b) Tính tổng các số dương ở dòng 2, ghi kết quả vào tệp TD.OUT theo cấu trúc:
+ Dòng 1: Ghi số nguyên S là tổng các số dương tìm được
c) Đếm số lượng các số chẵn ở dòng 2, ghi kết quả vào tệp SOCHAN.OUT theo cấu trúc:
+ Dòng 1: Ghi số nguyên k là số lượng số chẵn
+ Dòng 2: Ghi các số chẵn tìm được, các số ghi cách nhau 1 dấu cách trống.
d) Đếm số lượng các số âm chẵn ở dòng 2, ghi kết quả vào tệp SOAMCHAN.OUT theo cấu trúc:
+ Dòng 1: Ghi số nguyên k là số lượng số âm chẵn
+ Dòng 2: Ghi các số âm chẵn tìm được, các số ghi cách nhau 1 dấu cách trống.
e) Sắp xếp các số ở dòng 2 để được dãy không giảm, ghi kết quả vào tệp SAPXEP.OUT theo cấu trúc:
+ Dòng 1: Ghi dãy số đã được sắp xếp, các số ghi cách nhau 1 dấu cách trống.
f) Đếm số lượng các số nguyên tố ở dòng 2, ghi kết quả vào tệp NTO.OUT theo cấu trúc:
+ Dòng 1: Ghi số nguyên k là số lượng số nguyên tố
+ Dòng 2: Ghi các số nguyên tố tìm được, các số ghi cách nhau 1 dấu cách trống.
HƠI DÀI NHMA MONG MẤY BẠN GIÚP CHỨ MÌNH CHỊU R
AI GIÚP EM NHANH VỚI Ạ CHIỀU EM THI RỒI
cho tệp SO.TXT gồm nhiều số nguyên viết chương trình đọc dữ liệu từ tệp SO.TXT và lưu vào máy nguyên A
uses crt;
const fi='so.txt'
var f1:text;
a:array[1..100]of integer;
n,i:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
for i:=1 to n do
write(a[i]:4);
close(f1);
readln;
end.