Text20. Дан текстовый файл. Заменить в нем все подряд идущие пробелы на один пробел.
Решение:
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 |
program Text20; var F_in,F_out: Text; Name,line: string; i:integer; begin Write('File name: '); Readln(Name); 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); While (pos(' ',line)<>0) do Delete(line,pos(' ',line),1); Writeln(F_out,line ); end; Close(F_in); Close(F_out); Erase(F_in); Rename(F_out,Name); end. |
Другие задачи из раздела Text можно посмотреть здесь.
Комментарии: