Guest User

Untitled

a guest
Jan 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.64 KB | None | 0 0
  1. program Project2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. var
  9.   words: array[0..9] of string[20];
  10.   stroki: array[0..99] of string;
  11.   stroka: array[0..255] of string;
  12.   n, m, i, j, counter: integer;
  13.   s: string;
  14.  
  15. procedure check(str: string);
  16. var
  17.   i: integer;
  18. begin
  19. for i:=0 to n-1 do if str=words[i] then
  20.   begin
  21.   inc(counter);
  22.   words[i]:='.';
  23.   end;
  24. end;
  25.  
  26. begin
  27. readln(n);
  28. for i:=0 to n-1 do readln(words[i]);
  29. readln(m);
  30. for i:=0 to m-1 do readln(stroki[i]);
  31.  
  32. counter:=0;
  33. for i:=0 to m-1 do begin
  34.                    //çàìåíÿåì çíàêè ïðåïèíàíèÿ ïðîáåëàìè
  35.                    for j:=1 to length(stroki[i]) do if (stroki[i][j]='!') or (stroki[i][j]='?') or (stroki[i][j]=',') or (stroki[i][j]='.') then stroki[i][j]:=' ';
  36.                    //óäàëÿåì äâîéíûå ïðîáåëû, åñëè îíè ïîëó÷èëèñü
  37.                    while pos('  ', stroki[i])>0 do delete(stroki[i], pos('  ', stroki[i]), 1);
  38.                    //óäàëÿåì ïðîáåëû ñ êîíöà ñòðîê, åñëè îíè òàì ïîëó÷èëèñü
  39.                    if stroki[i][length(stroki[i])]=' ' then delete(stroki[i], length(stroki[i]), 1);
  40.                    while pos(' ', stroki[i])>0 do begin
  41.                                                   s:=copy(stroki[i], 1, pos(' ', stroki[i])-1);
  42.                                                   delete(stroki[i], 1, pos(' ', stroki[i]));
  43.                                                   check(s);
  44.                                                   end;
  45.                    check(stroki[i]);
  46.                    end;
  47.  
  48. writeln(counter);
  49. readln;
  50. end.
Add Comment
Please, Sign In to add comment