SHARE
TWEET

Untitled

a guest Aug 20th, 2018 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE Stek3;
  2. FROM Info IMPORT InfoTip;
  3. FROM Stek IMPORT StekTip,Top,Pop,Push,MakeNull,Empty;
  4. FROM FIO IMPORT File,Open,Create,RdStr,WrStr,WrLn,EOF;
  5. FROM InOut IMPORT WriteString,WriteLn;
  6. TYPE
  7.    String= ARRAY [1..100] OF CHAR;
  8.  
  9. PROCEDURE Ucitaj(file: String;VAR s1,s2: StekTip);
  10. VAR
  11.    f: File;
  12.    s: InfoTip;
  13.    ok: BOOLEAN;
  14. BEGIN
  15.    f:= Open(file);
  16.    EOF:= FALSE;
  17.    WHILE NOT EOF DO
  18.       RdStr(f,s);
  19.       Push(s1,s,ok);
  20.       IF NOT EOF THEN
  21.          RdStr(f,s);
  22.      Push(s2,s,ok);
  23.       END;
  24.    END;
  25. END Ucitaj;
  26.  
  27. PROCEDURE Skrati(VAR s1,s2: StekTip);
  28.  
  29.    PROCEDURE Obrni(s: InfoTip): InfoTip;
  30.    VAR
  31.       i: CARDINAL;
  32.       pom: CHAR;
  33.    BEGIN
  34.       i:= 1;
  35.       WHILE (i > LENGTH(s)-i+1) DO
  36.          pom:= s[i];
  37.      s[i]:= s[LENGTH(s)-i+1];
  38.      s[LENGTH(s)-i+1]:= pom;
  39.      INC(i);
  40.       END;
  41.       RETURN s;
  42.    END Obrni;
  43.  
  44. VAR
  45.    s,so,sl1,sl2: InfoTip;
  46.    ok: BOOLEAN;
  47. BEGIN
  48.    Top(s1,s,ok);
  49.    Pop(s1,ok);
  50.    Top(s1,sl1,ok);
  51.    Pop(s1,ok);
  52.    Top(s1,sl2,ok);
  53.    WHILE ((LENGTH(s) > LENGTH(sl1)) OR (LENGTH(s) > LENGTH(sl2))) DO
  54.       WriteString("WHILE");
  55.       so:= Obrni(s);
  56.       Push(s2,so,ok);
  57.       Push(s1,sl1,ok);
  58.       Top(s1,s,ok);
  59.       Pop(s1,ok);
  60.       Top(s1,sl1,ok);
  61.       Pop(s1,ok);
  62.       Top(s1,sl2,ok);
  63.    END;
  64.    Push(s1,sl1,ok);
  65.    Push(s1,s,ok);
  66. END Skrati;
  67.  
  68. PROCEDURE Stampaj(s: StekTip);
  69. VAR
  70.    str: InfoTip;
  71.    ok: BOOLEAN;
  72. BEGIN
  73.    WriteLn;
  74.    WHILE NOT Empty(s) DO
  75.       Top(s,str,ok);
  76.       Pop(s,ok);
  77.       WriteLn;
  78.       WriteString(str);
  79.    END;
  80. END Stampaj;
  81.  
  82. VAR
  83.    s1,s2: StekTip;
  84.  
  85. BEGIN
  86.    Ucitaj("st.txt",s1,s2);
  87.    Skrati(s1,s2);
  88.    Stampaj(s1);
  89.    Stampaj(s2);
  90. END Stek3.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top