Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MODULE drugi;
  2. FROM stek IMport Stack,makenull,empty,pop,push,top;
  3. FROM FIO IMPORT Open,close,file,eof,rdint,wrint,wrstr,wrln,rdcard,ok,rdchar,wrcard;
  4. from inout import writestring,writeln;
  5. from infotip import infotip;
  6. VAr
  7.     s1,s2:Stack;
  8.     x,y,z: infotip;
  9.     f:file;
  10.     c:char;
  11.     ok:boolean;
  12. begin
  13.     f:=open('br.txt');
  14.     eof:=false;
  15.     while not eof do
  16.        x:=rdcard(f);
  17.        push(s1,x,ok);
  18.        x:=rdcard(f);
  19.        Push(s2,x,ok);
  20.     end;
  21.     close(f);
  22.     f:=create(.prvi.txt');
  23.     While not Empty(s1) do
  24.        top(s1,x,ok);
  25.        pop(s1,ok);
  26.        IF not odd(x) Do
  27.         wrcard(f,x,1);
  28.         wrln(f);
  29.        end;
  30.     end;
  31.     close(f);
  32.     f:=Create('drugi.txt');
  33.     top(s2,x,ok);
  34.     pop(s2,ok);
  35.     top(s2,y,ok);
  36.     pop(s2,ok);
  37.     top(s2,z,ok);
  38.     pop(s2,ok);
  39.     WHILe not empty(s2) DO
  40.        IF x>y THE
  41.           wrcard(f,x,2);
  42.           wrln(f);
  43.           pop(s2,ok);
  44.        ELSE
  45.           pop(s2,ok);
  46.        end;
  47.        top(s2,x,ok);
  48.        pop(s2,ok);
  49.        top(s2,y,ok);
  50.        IF ok then
  51.         pop(s2,ok);
  52.         push(s2,y,ok);
  53.         push(s2,x,ok);
  54.        ELSE
  55.         wrcard(f,x,2);
  56.         wrln(f);
  57.        end;
  58.     end;
  59.     CLOSE(f);
  60. END drugi.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement