Advertisement
ridjis

zadatak 3.9a

Jun 4th, 2014
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE zad39a;
  2. FROM Info IMPORT InfoTip;
  3. FROM RedOpsl IMPORT RedOpslTip,First,PopFirst,AddRear,Empty,MakeNull;
  4. FROM InOut IMPORT WriteString,ReadString;
  5. FROM FIO IMPORT File,Open,Create,Close,EOF,RdStr,WrStr,WrLn;
  6. FROM Str IMPORT Length;
  7.  
  8. CONST str1 = "str1.txt"; //sadrzaj: neki stringovi
  9.       str2 = "str2.txt"; //sadrzaj: neki stringovi
  10.  
  11. VAR string : InfoTip;
  12.     red1,red2,redStr:RedOpslTip;
  13.     ok:BOOLEAN;
  14.  
  15. PROCEDURE Ucitaj(imeF:ARRAY OF CHAR; VAR red:RedOpslTip; VAR ok:BOOLEAN);
  16. VAR f:File;
  17.     str : InfoTip;
  18. BEGIN
  19.   MakeNull(red);
  20.   f:=Open(imeF);
  21.   EOF:=FALSE;
  22.   WHILE NOT EOF DO
  23.     RdStr(f,str);
  24.     AddRear(red,str,ok);
  25.   END;
  26.   Close(f);
  27. END Ucitaj;
  28.  
  29. PROCEDURE Spaja(VAR r1,r2,r3:RedOpslTip;VAR ok:BOOLEAN);
  30. VAR str : InfoTip;
  31. BEGIN
  32.   MakeNull(r3);
  33.   WHILE NOT Empty(r1) OR NOT Empty(r2) DO
  34.     IF NOT Empty(r1) THEN
  35.       First(r1,str,ok);
  36.       AddRear(r3,str,ok);
  37.       PopFirst(r1,ok);
  38.     END;
  39.     IF NOT Empty(r2) THEN
  40.       First(r2,str,ok);
  41.       AddRear(r3,str,ok);
  42.       PopFirst(r2,ok);
  43.     END;
  44.   END;
  45. END Spaja;
  46.  
  47. PROCEDURE Odstranjuje(VAR red:RedOpslTip;VAR ok:BOOLEAN);
  48. VAR str : InfoTip;
  49.     m:BOOLEAN;
  50. BEGIN
  51.   m:=TRUE;
  52.   WHILE m AND NOT Empty(red) DO
  53.     First(red,str,ok);
  54.     IF Length(str) > 4 THEN
  55.       PopFirst(red,ok);
  56.     ELSE
  57.       m:=FALSE;
  58.     END;
  59.   END;
  60. END Odstranjuje;
  61.  
  62. PROCEDURE SnimiRed(imeF:ARRAY OF CHAR; VAR red:RedOpslTip;VAR ok:BOOLEAN);
  63. VAR f:File;
  64.     str : InfoTip;
  65. BEGIN
  66.   f:=Create(imeF);
  67.   WHILE NOT Empty(red) DO
  68.     First(red,str,ok);
  69.     WrStr(f,str);
  70.     PopFirst(red,ok);
  71.     WrLn(f);
  72.   END;
  73.   Close(f);
  74. END SnimiRed;
  75.  
  76. BEGIN
  77.   Ucitaj(str1,red1,ok);
  78.   Ucitaj(str2,red2,ok);
  79.  
  80.   Spaja(red1,red2,redStr,ok);
  81.  
  82.   Odstranjuje(redStr,ok);
  83.  
  84.   WriteString('Unesite ime fajla: ');
  85.   ReadString(string);
  86.   SnimiRed(string,redStr,ok);
  87.  
  88. END zad39a.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement