gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cced323)
raw | patch | inline | side by side (parent: cced323)
author | Doni Pracner <quinnuendo@gmail.com> | |
Mon, 21 Oct 2013 12:50:01 +0000 (14:50 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Mon, 21 Oct 2013 12:50:01 +0000 (14:50 +0200) |
02. Podslika/XDS/MALA.SLI | [new file with mode: 0644] | patch | blob |
02. Podslika/XDS/PODSLIKA.MOD | [new file with mode: 0644] | patch | blob |
02. Podslika/XDS/VELIKA.SLI | [new file with mode: 0644] | patch | blob |
diff --git a/02. Podslika/XDS/MALA.SLI b/02. Podslika/XDS/MALA.SLI
--- /dev/null
@@ -0,0 +1,6 @@
+5\r
+ 0 0 1 0 0\r
+ 0 1 1 1 0\r
+ 1 1 2 1 1\r
+ 0 1 1 1 0\r
+ 0 0 1 0 0\r
diff --git a/02. Podslika/XDS/PODSLIKA.MOD b/02. Podslika/XDS/PODSLIKA.MOD
--- /dev/null
@@ -0,0 +1,168 @@
+MODULE Podslika;\r
+\r
+ FROM FIO IMPORT\r
+ File, Open, Close, RdCard, EOF, Exists;\r
+ FROM IO IMPORT\r
+ WrLn, WrStr, WrCard;\r
+\r
+ CONST\r
+ MaxDim = 100;\r
+ BrojBoja = 16;\r
+ Osnova = MaxDim * (BrojBoja - 1) + 1;\r
+ ProstBroj = 3001;\r
+ ImeVel = 'Velika.Sli';\r
+ ImeMal = 'Mala.Sli';\r
+\r
+ TYPE\r
+ \r
+ Slika = ARRAY [1 .. MaxDim], [1 .. MaxDim] OF CARDINAL;\r
+\r
+ VAR\r
+ Velika, Mala: Slika;\r
+ DimVel, DimMal, Vr, Ko: CARDINAL;\r
+ KljucMale, KljucSegmenta, Stepen: CARDINAL;\r
+ Ok, Iste: BOOLEAN;\r
+\r
+ PROCEDURE Citaj(VAR Slika: Slika;\r
+ Ime: ARRAY OF CHAR;\r
+ VAR Dim: CARDINAL;\r
+ VAR Ok: BOOLEAN);\r
+ VAR\r
+ F: File;\r
+ Vr, Ko: CARDINAL;\r
+ Jos: BOOLEAN;\r
+ BEGIN\r
+ Ok:= Ok AND Exists(Ime);\r
+ IF Ok THEN\r
+ F:= Open(Ime);\r
+ Dim:= RdCard(F);\r
+ Vr:= 1;\r
+ Jos:= TRUE;\r
+ WHILE Jos AND (Vr <= Dim) DO\r
+ Ko:= 1;\r
+ WHILE Jos AND (Ko <= Dim) DO\r
+ Slika[Vr, Ko]:= RdCard(F);\r
+ Ok:= Ok AND (Slika[Vr, Ko] < BrojBoja);\r
+ Jos:= Ok AND NOT EOF;\r
+ INC(Ko);\r
+ END;\r
+ INC(Vr);\r
+ END;\r
+ Close(F);\r
+ ELSE\r
+ Dim:= 0;\r
+ END;\r
+ END Citaj;\r
+\r
+ PROCEDURE Proveri(VAR Velika, Mala: Slika;\r
+ DimMal, Vr, Ko: CARDINAL): BOOLEAN;\r
+ VAR\r
+ i, j: CARDINAL;\r
+ Iste: BOOLEAN;\r
+ BEGIN\r
+ Iste:= TRUE;\r
+ i:= 1;\r
+ WHILE Iste AND (i <= DimMal) DO\r
+ j:= 1;\r
+ WHILE Iste AND (j <= DimMal) DO\r
+ IF Mala[i, j] # Velika[Vr + i - 1, Ko + j - 1] THEN\r
+ Iste:= FALSE;\r
+ END;\r
+ INC(j);\r
+ END;\r
+ INC(i);\r
+ END;\r
+ RETURN Iste;\r
+ END Proveri;\r
+\r
+ PROCEDURE Hash(S: Slika; DimMal, Vr: CARDINAL): CARDINAL;\r
+ VAR\r
+ i, j: CARDINAL;\r
+ Kljuc, ZbirKolone, Temp: CARDINAL;\r
+ BEGIN\r
+\r
+ Stepen:= 1;\r
+ Kljuc:= 0;\r
+\r
+ FOR i:= DimMal TO 1 BY -1 DO\r
+\r
+ ZbirKolone:= 0;\r
+ FOR j:= Vr TO Vr + DimMal - 1 DO\r
+ ZbirKolone:= ZbirKolone + (S[j, i]);\r
+ END;\r
+\r
+ Temp:= (ZbirKolone * Stepen) MOD ProstBroj;\r
+ Kljuc:= (Kljuc + Temp) MOD ProstBroj;\r
+ Stepen:= (Stepen * Osnova) MOD ProstBroj;\r
+\r
+ END;\r
+\r
+ Stepen:= Stepen DIV Osnova;\r
+\r
+ RETURN Kljuc;\r
+\r
+ END Hash;\r
+\r
+ PROCEDURE DoterajHash(S: Slika; DimMal, Vr, Ko: CARDINAL;\r
+ VAR Kljuc: CARDINAL);\r
+ VAR\r
+ j: CARDINAL;\r
+ ZbirKolone, Temp: CARDINAL;\r
+ BEGIN\r
+\r
+ ZbirKolone:= 0;\r
+ FOR j:= Vr TO Vr + DimMal - 1 DO\r
+ ZbirKolone:= ZbirKolone + (S[j, Ko - 1]);\r
+ END;\r
+\r
+ Temp:= (ZbirKolone * Stepen) MOD ProstBroj;\r
+\r
+ IF Kljuc >= Temp THEN\r
+ Kljuc:= Kljuc - Temp;\r
+ ELSE\r
+ Kljuc:= Kljuc + ProstBroj - Temp;\r
+ END;\r
+\r
+ Kljuc:= (Kljuc * Osnova) MOD ProstBroj;\r
+\r
+ ZbirKolone:= 0;\r
+ FOR j:= Vr TO Vr + DimMal - 1 DO\r
+ ZbirKolone:= ZbirKolone + (S[j, Ko + DimMal - 1]);\r
+ END;\r
+\r
+ Kljuc:= (Kljuc + ZbirKolone) MOD ProstBroj;\r
+\r
+ END DoterajHash;\r
+\r
+BEGIN\r
+ Ok:= TRUE;\r
+ Citaj(Velika, ImeVel, DimVel, Ok);\r
+ Citaj(Mala, ImeMal, DimMal, Ok);\r
+ IF Ok THEN\r
+ KljucMale:= Hash(Mala, DimMal, 1);\r
+ FOR Vr:= 1 TO (DimVel - DimMal + 1) DO\r
+ KljucSegmenta:= Hash(Velika, DimMal, Vr);\r
+ IF (KljucMale = KljucSegmenta) THEN\r
+ Iste:= Proveri(Velika, Mala, DimMal, Vr, 1);\r
+ IF Iste THEN\r
+ WrLn;\r
+ WrStr('Podslika je nadjena. Pocinje na poziciji (');\r
+ WrCard(Vr, 1); WrStr(', '); WrCard(1, 1); WrStr(')');\r
+ END;\r
+ END;\r
+ FOR Ko:= 2 TO (DimVel - DimMal + 1) DO\r
+ DoterajHash(Velika, DimMal, Vr, Ko, KljucSegmenta);\r
+ IF (KljucMale = KljucSegmenta) THEN\r
+ Iste:= Proveri(Velika, Mala, DimMal, Vr, Ko);\r
+ IF Iste THEN\r
+ WrLn;\r
+ WrStr('Podslika je nadjena. Pocinje na poziciji (');\r
+ WrCard(Vr, 1); WrStr(', '); WrCard(Ko, 1); WrStr(')');\r
+ END;\r
+ END;\r
+ END;\r
+ END;\r
+ ELSE\r
+ WrStr('Greska u citanju fajla.');\r
+ END;\r
+END Podslika.\r
diff --git a/02. Podslika/XDS/VELIKA.SLI b/02. Podslika/XDS/VELIKA.SLI
--- /dev/null
@@ -0,0 +1,13 @@
+12\r
+ 0 0 0 0 0 0 0 0 0 0 0 0\r
+ 0 0 0 0 0 0 0 0 0 0 0 0\r
+ 0 0 0 1 0 0 0 0 0 0 0 0\r
+ 0 0 1 1 1 0 0 0 0 0 0 0\r
+ 0 1 1 2 1 1 0 0 0 0 0 0\r
+ 0 0 1 1 1 0 5 5 5 0 0 0\r
+ 0 0 0 1 0 0 0 0 0 0 0 0\r
+ 0 0 0 0 0 5 0 0 1 0 0 0\r
+ 0 0 0 0 5 0 0 1 2 1 0 0\r
+ 0 0 0 5 0 0 1 2 15 2 1 0\r
+ 0 0 5 0 0 0 0 1 2 1 0 0\r
+ 0 0 0 0 0 0 0 0 1 0 0 0\r