pascal: tạo tệp SONGUYEN.DAT gồm N số nguyên
2 câu trả lời
var f: text;
n, i: byte;
a: integer;
Begin
Assign(f, 'songuyen.dat'); rewrite(f);
Write('nhap n = '); readln(n);
For i:=1 to n do
Begin
Write('nhap so thu ', i, ': ');
Readln(a); write(f, a, ' ');
End.
Close(f);
End.
program tao_tep;
uses crt;
var f:text;
n,i,k:integer;
begin
clrscr;
Assign(f,'SONGUYEN.DAT'); rewrite(f);
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(k);
write(f,k,' ');
end;
close(f);
end.