Advertisement
ridjis

A u B

Dec 4th, 2013
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (*koliko se puta string a nalazi u stringu b*)
  2. MODULE zadatak;
  3. FROM InOut IMPORT WriteString,WriteLn,ReadString,WriteCard;
  4. FROM Strings IMPORT Length;
  5.  
  6. TYPE
  7.     String = ARRAY [1..100] OF CHAR;
  8.  
  9. PROCEDURE Ucitaj(VAR str1,str2 : String) : CARDINAL;
  10. VAR
  11.     br,i,j : CARDINAL;
  12.     ok : BOOLEAN;
  13. BEGIN
  14.     WriteString("Unesite prvi string: ");
  15.     ReadString(str1);
  16.     WriteString("Unesite drugi string: ");
  17.     ReadString(str2);
  18.     j:=1;
  19.     br := 0;
  20.     FOR i:=1 TO Length(str2) DO
  21.         IF ORD(str1[j]) = ORD(str2[i]) THEN
  22.             INC(j);
  23.             IF (j > Length(str1)) THEN
  24.                 j:=1;
  25.                 INC(br);
  26.             END;
  27.             ELSE
  28.             j := 1;
  29.         END;
  30.     END;       
  31.     RETURN br;
  32. END Ucitaj;
  33.    
  34. VAR
  35.     a,b : String;
  36.     brPuta : CARDINAL;
  37. BEGIN
  38.     brPuta := Ucitaj(a,b);
  39.     WriteCard(brPuta,0);   
  40. END zadatak.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement