Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*napisati proceduru koja ucitava 2 stringa i proverava da li su stringovi jednaki(nije case sensitive)*)
- MODULE zad51_2;
- FROM InOut IMPORT WriteLn, WriteString, ReadString;
- FROM Str IMPORT Length;
- CONST max=256;
- TYPE stringovi= ARRAY [1..max] OF CHAR;
- VAR str1, str2: stringovi;
- ch: CHAR;
- jednak: BOOLEAN;
- i: CARDINAL;
- PROCEDURE uVelSlovo(ch : CHAR) : CHAR;
- BEGIN
- IF ('a' <= ch) AND (ch <= 'z') THEN
- RETURN CAP(ch)
- ELSE
- RETURN ch;
- END;
- END uVelSlovo;
- PROCEDURE poredi(VAR str1, str2: stringovi) : BOOLEAN;
- BEGIN
- jednak:= TRUE;
- i:=1;
- WHILE(str1[i] #0C) AND (str1[i] #0C ) AND jednak DO
- IF str1[i] = str2[i] THEN
- INC(i);
- ELSE
- jednak:=FALSE;
- END;
- END;
- RETURN jednak;
- IF jednak THEN
- IF NOT (str1[i] = 0C) AND (str2[i] = 0C) THEN
- jednak:= FALSE;
- RETURN jednak
- END;
- RETURN jednak
- END;
- END poredi;
- BEGIN
- WriteString('Unesite 1. string: ');
- ReadString(str1);
- FOR i:=1 TO Length(str1) DO
- str1[i]:=uVelSlovo(ch);
- END;
- WriteLn;
- WriteString('Unesite 2. string: ');
- ReadString(str2);
- FOR i:=1 TO Length(str1) DO
- str2[i]:=uVelSlovo(ch);
- END;
- WriteLn;
- IF poredi(str1,str2) THEN
- WriteString('Stringovi su jednaki.');
- ELSE
- WriteString('Stringovi nisu jednaki.');
- END;
- WriteLn;
- END zad51_2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement