Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program task4;
- // Открытие файла
- procedure OpenFile(var f: text; fname: string);
- var
- fileName: string;
- begin
- // write('Введите имя файла: ');
- // Readln(fileName);
- assign(f, fname);
- reset(f);
- end;
- // Вывод строк файла на экран. Перед строкой отображается еѐ
- // номер в файле
- procedure PrintFile(var f: text);
- var
- ch: char;
- num, pos: integer; // num – номер строки в файле
- begin
- num := 1;
- write(num, ' ');
- reset(f);
- while not eof(f) do
- begin
- Read(f, ch);
- Dec(pos);
- if ch = #10 then
- continue;
- if ch = #13 then // переходим к следующей строке
- begin
- writeln;
- Inc(num);
- write(num, ' ');
- continue;
- end;
- write(ch);
- end;
- end;
- procedure copyLettersInOutFile(var inf: text; var outf: text);
- var
- symbol: char;
- begin
- assign(outf, 'out.txt');
- rewrite(outf);
- symbol := 'a';
- while not eof(inf) do
- begin
- Read(inf, symbol);
- if symbol = #10 then
- continue;
- if symbol = #13 then
- begin
- Write(outf, #13);
- continue;
- end;
- if not(symbol in ['0' .. '9']) then
- Write(outf, symbol);
- end;
- close(outf);
- end;
- var
- inFile, outFile: text;
- cancel: integer;
- begin
- OpenFile(inFile, 'in.txt');
- copyLettersInOutFile(inFile, outFile);
- PrintFile(outFile);
- close(inFile);
- read(cancel);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement