FILE.PAS 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. Const
  2. file1 = 'input.txt';
  3. file2 = 'strings.txt';
  4. file3 = 'numbers.lnt';
  5. nums = ['0'..'9'];
  6. Var
  7. ch : char;
  8. numstr : string;
  9. i : integer;
  10. f1 : text;
  11. f2 : text;
  12. f3 : file of longint;
  13. num : longint;
  14. code : integer;
  15. mode : boolean;
  16. Begin
  17. Assign(f1,file1);
  18. Reset(f1);
  19. Assign(f2,file2);
  20. Rewrite(f2);
  21. Assign(f3,file3);
  22. Rewrite(f3);
  23. mode := false;
  24. repeat
  25. read(f1,ch);
  26. if mode then
  27. begin
  28. if ch in nums then numstr := numstr+ch
  29. else
  30. begin
  31. mode := false;
  32. Write(f2,ch);
  33. if length(numstr) < 10 then
  34. begin
  35. val(numstr,num,code);
  36. Write(f3,num);
  37. end
  38. else Write(f2,numstr);
  39. end;
  40. end
  41. else
  42. begin
  43. if ch in nums then
  44. begin
  45. mode := true;
  46. numstr := ch;
  47. end
  48. else Write(f2,ch);
  49. end;
  50. until EOF(f1);
  51. Close(f1);
  52. Close(f2);
  53. Close(f3);
  54. End.