Advertisement
dikdack

Untitled

Dec 22nd, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.37 KB | None | 0 0
  1. Program dz5_1;
  2. uses crt;
  3.  
  4. type
  5.   sl = string[30];
  6.   fil = file of sl;
  7.  
  8. var
  9.   s: fil;
  10.   slovo: sl;
  11.   mas: array [1..100] of sl;
  12.   N, ch, i: integer;
  13.   check: char;
  14.  
  15. procedure readx;
  16. begin
  17.   assign (s, 'C:\Users\Xiaomi\Desktop\qqq.dat');
  18.   reset (s);
  19.   i:=1;
  20.   while not eof (s) do begin
  21.     read(s, slovo);
  22.     mas[i] := slovo;
  23.     inc(i);
  24.   end;
  25.   close(s);
  26. end;
  27.  
  28. procedure writex;
  29. begin
  30.   assign (s, 'C:\Users\Xiaomi\Desktop\qqq.dat');
  31.   rewrite (s);
  32.   writeln('How?');
  33.   readln(N);
  34.   ch := N;
  35.   writeln('Input words:');
  36.   while (N>0) do
  37.   begin
  38.     readln(slovo);
  39.     write(s,slovo);
  40.     dec(N);
  41.   end;
  42.   close(s);
  43. end;
  44.  
  45. procedure output;
  46. var j:integer;
  47. begin
  48.   writeln('Words from file:');
  49.   for j:=1 to ch do
  50.     writeln(mas[j]);
  51. end;
  52.  
  53. procedure checkx;
  54. var i, j, p: integer;
  55. begin
  56.   for i:=1 to ch do
  57.     for j:=i+1 to ch do
  58.       if mas[i]=mas[j] then
  59.       begin
  60.         dec(ch);
  61.         for p:= j to ch-1 do
  62.           mas[p]:=mas[p+1];
  63.       end;
  64.    writeln('Without povtor:');
  65.    for i:=1 to ch do
  66.      writeln(mas[i]);
  67.    
  68. end;
  69.  
  70. begin
  71.   check := 'a';
  72.   while check <> 'q' do
  73.   begin
  74.     writex;
  75.     readx;
  76.     output;
  77.     checkx;
  78.     Write('If you want to exit press "q", if you want to continue: open qqq.txt, enter a new text, save, press random botton: ');
  79.     readln (check);
  80.     writeln;
  81.   end;
  82. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement