Tassos

Αντιγραφή χωρίς διπλά κενά (Pascal)

Feb 9th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.77 KB | None | 0 0
  1. {                              Visit:   http://g-lts.no-ip.info/  for more code!              }
  2. program antigrafi;
  3.  
  4. type fchar = file of char;
  5.  
  6. // diadikasi pou diabazi to arxio ke to ektiponi.
  7.  
  8. procedure readfile ( var f:fchar);
  9. begin
  10.  
  11.     reset(f);
  12.  
  13.     while not eof(f) do
  14.     begin
  15.         write (f^);
  16.         get(f);
  17.     end;
  18.  
  19. end;
  20.  
  21. // telos diadikasias read file
  22. // =======================================================
  23. // Diadikasia copy file
  24.  
  25. procedure copyfile  (var f:fchar; var g:fchar);
  26.  
  27. var b:boolean;
  28. begin
  29.     reset(f);
  30.     rewrite(g);
  31.     b := true;
  32.  
  33.     // gia ta prota spaces osa briski de ta metaferi...
  34.     while ( (not eof(f)) and (f^=' ') ) do
  35.         get(f);
  36.  
  37.     // ke otan bri kati allo pera apo ta prota spaces genika gia oti periexi..
  38.  
  39.     while not eof(f) do
  40.     begin
  41.         if (f^=' ') then
  42.         begin
  43.             if b=false then
  44.             begin
  45.                 g^:=f^;
  46.                 put(g);
  47.                 b:=true;
  48.             end;
  49.             get(f);
  50.         end
  51.         else
  52.         begin  
  53.             g^:=f^;
  54.             put(g);
  55.             b:=false;
  56.             get(f);
  57.         end;
  58.     end;
  59. end;
  60.  
  61. // Telos diadikasias copy file
  62. // =======================================================
  63. // Kirio programm..
  64.  
  65. var f,g:fchar; epilogi:integer;
  66.  
  67. begin
  68.     assign (f,'fim.txt');
  69.     assign (g,'font.txt');
  70.  
  71.     readfile(f); // gia na doume to fim ( me ta epipleon kena (spaces)
  72.     writeln(''); // gia logous kalopismou :P
  73.     copyfile(f,g);
  74.     writeln ('Αντιγραφή αρχείων........................[OK].');
  75.     writeln ('Θέλετε να δείτε το αντιγραμμένο αρχείο;');
  76.     writeln ('1 = Ναι.');
  77.     writeln ('2 = Όχι, Έξοδος.');
  78.     read (epilogi);
  79.     if epilogi=1 then
  80.         readfile(g)
  81.     else
  82.         writeln ('Άντε γεια. :)');
  83.                              
  84. end.
  85. {                              Visit:   http://g-lts.no-ip.info/  for more code!              }
Advertisement
Add Comment
Please, Sign In to add comment