Text18. Дано целое число $$K$$ и текстовый файл. Удалить из каждой строки файла первые $$K$$ символов (если длина строки меньше $$K$$, то удалить из нее все символы).
Решение:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
program Text18; var F_in,F_out: Text; Name,line: string; K:integer; begin Write('File name: '); Readln(Name); Write('K: '); Readln(K); Assign(F_in,Name); Assign(F_out,'~'+Name); Reset(F_in); Rewrite(F_out); While not eof(F_in) do begin Readln(F_in,line); Delete(line,1,K); Writeln(F_out,line); end; Close(F_in); Close(F_out); Erase(F_in); Rename(F_out,Name); end. |
Другие задачи из раздела Text можно посмотреть здесь.
Комментарии: