Advertisement
ridjis

isti stringovi

Nov 28th, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (*napisati proceduru koja ucitava 2 stringa i proverava da li su stringovi jednaki(nije case sensitive)*)
  2. MODULE zad51_2;
  3. FROM InOut IMPORT WriteLn, WriteString, ReadString;
  4. FROM Str IMPORT Length;
  5. CONST max=256;
  6. TYPE    stringovi= ARRAY [1..max] OF CHAR;
  7. VAR str1, str2: stringovi;
  8.     ch: CHAR;
  9.     jednak: BOOLEAN;
  10.     i: CARDINAL;
  11.  
  12. PROCEDURE uVelSlovo(ch : CHAR) : CHAR;
  13. BEGIN
  14.   IF ('a' <= ch) AND (ch <= 'z') THEN
  15.     RETURN CAP(ch)
  16.   ELSE
  17.     RETURN ch;
  18.   END;
  19. END uVelSlovo;
  20.  
  21. PROCEDURE poredi(VAR str1, str2: stringovi) : BOOLEAN;
  22. BEGIN
  23.   jednak:= TRUE;
  24.   i:=1;
  25.   WHILE(str1[i] #0C) AND (str1[i] #0C ) AND jednak DO
  26.     IF str1[i] = str2[i] THEN
  27.       INC(i);
  28.     ELSE
  29.       jednak:=FALSE;
  30.     END;
  31.   END;
  32.   RETURN jednak;
  33.  
  34.   IF jednak THEN
  35.     IF NOT (str1[i] = 0C) AND (str2[i] = 0C) THEN
  36.       jednak:= FALSE;
  37.       RETURN jednak
  38.     END;
  39.     RETURN jednak
  40.   END;
  41. END poredi;
  42. BEGIN
  43.   WriteString('Unesite 1. string: ');
  44.   ReadString(str1);
  45.   FOR i:=1 TO Length(str1) DO
  46.     str1[i]:=uVelSlovo(ch);
  47.   END;
  48.   WriteLn;
  49.   WriteString('Unesite 2. string: ');
  50.   ReadString(str2);
  51.   FOR i:=1 TO Length(str1) DO
  52.     str2[i]:=uVelSlovo(ch);
  53.   END;
  54.   WriteLn;
  55.   IF poredi(str1,str2) THEN
  56.     WriteString('Stringovi su jednaki.');
  57.   ELSE
  58.     WriteString('Stringovi nisu jednaki.');
  59.   END;
  60.   WriteLn;
  61. END zad51_2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement