From: MX%"antek@mimuw.edu.pl" 1-MAR-1993 16:00:42.56 To: SALWICKI CC: Subj: Date: Mon, 1 Mar 93 14:59:41 GMT From: antek@mimuw.edu.pl To: salwicki@pauvx1.univ-pau.fr /* program mergecor; unit node: class; var left,right : node, val : integer; unit ins: procedure( value: integer) ; begin if val > value then if left=none then left:=new node; left.val:=value; else call left.ins(value); fi; else if right = none then right:=new node; right.val:=value; else call right.ins(value) fi; fi; end ins; end node; unit traverse : coroutine (i:integer); var val: integer, x: node; unit t: procedure(y:node); begin if y=/=none then call t(y.left); val:=y.val; detach; call t(y.right); fi; end t; begin x:=d(i); return; call t(x); detach with endtree(i); end traverse; signal endtree(t:integer),fin ; var n,i,j,min,m,k: integer, d: arrayof node, tr: arrayof traverse, bb: integer; exceptions when endtree: if bb=1 then raise fin fi; bb:=1; if t=1 then j:=2 else j:=1 fi; do write(tr(j).val); writeln; attach(tr(j)) od; when fin : terminate; begin read(n); array d dim(1:n); for i:=1 to n do read(j); write(j); if j>m then m:=j fi; d(i):=new node; d(i).val:=j; do read(j); if j=-1 then writeln; exit fi; write(j); if j>m then m:=j fi; call d(i).ins(j) od; od; array tr dim (1:n); min:=0; for i:=1 to n do tr(i):=new traverse(i); attach(tr(i)); od; k:=0; do min:=tr(1).val; j:=1; for i:=2 to n do if min > tr(i).val then min:=tr(i).val; j:=i fi; od; write(min); attach(tr(j)); k:=k+1; if k=10 then writeln; k:=0 fi; od; writeln; end mergecor */ #include "rsdata.h" extern int IC; /* global control */ extern int modulenumber; /* module number */ extern unsigned int *DISPVIRT,*DISPDIR; /* displays' addresses */ extern unsigned int *lastcor,*mycoroutine,*myprocess; extern unsigned int *current,*local,*global; #define numprot 8 int displ= -6; int displdir = -15; int curr= -8; int lstcor= -10; int chead = -12; int protnum=numprot; int offnum=4; int perm [] = { 0,1,2}; int perminv [] = { 0,1,2}; struct Prototype PROT [] = /* kind num lspn rspn ref dcl lev lst pmdd Sl DL Lsc Stat hand pref pslen */ { {2, 0, 15, 27, 0, -1, 0, 7, 0, 27, 26, 25, 24, 0, -1, 1}, {0, 1, 0, 9, 1, 0, 1, 2, 0, 9, 8, 7, 6, -1, -1, 1}, {1, 2, 0, 9, 2, 1, 2, 6, 0, 9, 8, 7, 6, -1, -1, 1}, {3, 3, 1, 9, 3, 0, 1, 4, 0, 9, 8, 7, 6, -1, -1, 1}, {1, 4, 0, 9, 4, 3, 2, 5, 0, 9, 8, 7, 6, -1, -1, 1}, {7, 5}, {4, 6, 0, 9, 1, 0, 1, 4, 0, 9, 8, 7, 6, 0}, {4, 7, 0, 9, 1, 0, 1, 2, 0, 9, 8, 7, 6, 0} }; int (* module [numprot]) () ; jmp_buf buffer; struct Offsets OFF[]= { 0, 43, 0, 11, 0, 0, 0, 0, 10, 1, 2, 0, 11, 0, 0, 10, 2, 3, 0, 13, 0, 0, 10, 3, 4, 0, 16, 0, 0, 10, 4, 4, 0, 20, 0 }; struct Elem EL[]= { 7, 1, 0, 9, 2, 0, 16, 3, 0, -6, 4, 0, -4, 5, 0, -2, 6, 0, -8, 7, 0, -10, 8, 0, -12, 9, 0, 26, 10, 1, 27, -1, 2, 1, 12, 0, 3, -1, 0, 2, 14, 0, 8, 15, 1, 9, -1, 2, 1, 17, 0, 4, 18, 0, 8, 19, 1, 9, -1, 2, 1, 21, 0, 3, 22, 0, 8, 23, 1, 9, -1, 2}; struct Hlstelem HL[]= { 6,0,1, 7,1,-1 }; struct Sgelem SL[]= { 101,-1, 102, -1 }; node() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: Endclass(); L2: Killafter(); Endclass(); } ins() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; case 5: goto L5; break; case 6: goto L6; break; }; L1: if (*Address(1,5) > *Local(1)) { if (Notmember(Address(1,1))) { Dopen(1,0,Address(1,1)); IC=2; Go(Address(1,1)); L2: *(Physical(Address(1,1))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,1)); *(Physical(Local(2))+1)= *Local(1); IC=3; Go(Local(2)); L3: Killafter() ; }; } else { if (Notmember(Address(1,3))) { Dopen(1,0,Address(1,3)); IC=4; Go(Address(1,3)); L4: *(Physical(Address(1,3))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,3)); *(Physical(Local(2))+1)= *Local(1); IC=5; Go(Local(2)); L5: Killafter(); }; }; Back(); L6: Killafter(); Back(); } trav() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: Refmove(Local(1),Arrayelem(Global(7),*Local(-1))); IC=2; Back(); L2: Dopen(4,3,Local(4)); Refmove(Physical(Local(4))+1,Local(1)); IC=3; Go(Local(4)); L3: Killafter(); Attachwith(lastcor,101,Local(4)); *(Physical(Local(4))+5)= *Local(-1); Attach(lastcor); Endcor(); L4: Killafter(); Endcor(); } t() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; case 5: goto L5; break; }; L1: if (Member(Local(1))) { Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+1); IC=2; Go(Local(3)); L2: Killafter(); *Address(1,3)= *(Physical(Local(1))+5); IC=3; Attach(lastcor); L3: Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+3); IC=4; Go(Local(3)); L4: Killafter(); }; Back(); L5: Killafter(); Back(); } merge() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; case 5: goto L5; break; case 6: goto L6; break; case 7: goto L7; break; }; L1: printf("Number of trees n=2\n"); *Global(1)=2; Openarray(5,1,*Global(1),Global(7)); printf("Give the values of nodes. End each tree with -1\n"); *Global(2)=1; while (1) { if (*Global(2)> *Global(1)) break; scanf("%d",Global(3)); if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Dopen(1,0,Arrayelem(Global(7),*Global(2))); IC=2; Go(Arrayelem(Global(7),*Global(2))); L2: *(Physical(Arrayelem(Global(7),*Global(2)))+5)= *Global(3); while(1) { scanf("%d",Global(3)); if (*Global(3) == -1) break; if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Slopen(2,Global(16),Arrayelem(Global(7),*Global(2))); *(Physical(Global(16))+1)= *Global(3); IC=3; Go(Global(16)); L3: Killafter(); }; (*Global(2))++; }; (*Global(5))++; Openarray(5,1,*Global(1),Global(9)); *Global(4)=0; *Global(2)=1; while(1) { if (*Global(2) > *Global(1)) break; Dopen(3,0,Arrayelem(Global(9),*Global(2))); *(Physical(Arrayelem(Global(9),*Global(2)))-1)= *Global(2); IC=4; Go(Arrayelem(Global(9),*Global(2))); L4: IC=5; Attach(Arrayelem(Global(9),*Global(2))); L5: (*Global(2))++; }; *Global(6)=0; while(1) { if (*Global(4) == *Global(5) ) break; *Global(4)= *(Physical(Arrayelem(Global(9),1))+3); *Global(3)=1; *Global(2)=2; while (1) { if (*Global(2) > *Global(1)) break; if (*Global(4) > *(Physical(Arrayelem(Global(9),*Global(2)))+3)) { *Global(4) = *(Physical(Arrayelem(Global(9),*Global(2)))+3); *Global(3)= *Global(2); }; (*Global(2))++; }; if (*Global(4) < *Global(5)) { printf("%d ",*Global(4)); IC=6; Attach(Arrayelem(Global(9),*Global(3))); L6: (*Global(6))++; if (*Global(6)==10) { printf(" \n"); *Global(6)=0; }; }; }; Endrun(); L7: Killafter(); Endrun(); } endtree() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: if (*Global(18)) { Raising(102,Address(1,1)); IC=2; Go(Address(1,1)); L2: ; }; *Global(18)= 1; if (*Address(1,5)==1) *Global(3)=2; else *Global(3)=1; while(1) { if (IC==0) break; /* dummy */ printf("%d ",*(Physical(Arrayelem(Global(9),*Global(3)))+3)); (*Global(6))++; if (*Global(6)==10) { printf(" \n"); *Global(6)=0; }; IC=3; Attach(Arrayelem(Global(9),*Global(3))); L3: ; }; Back(); L4: Killafter(); Back(); } fin() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: Termination(); Back(); L2: Killafter(); Back(); } main () { Init(); module[0]=merge; module[1]=node; module[2]=ins; module[3]=trav; module[4]=t; module[6]=endtree; module[7]=fin; IC=1; modulenumber=0; if (setjmp(buffer)!=-2) module[modulenumber](); } /* program pawel; var n,m; unit F: procedure; var i: integer; begin if m=n+1 then for i:=1 to n do write(A[i]," "); od; writeln; else for i:=1 to n do if A[i]=0 then A[i]:=m; m:=m+1; F; m:=m-1; A[i]:=0; fi; od; fi; end F; begin write("Generation of all permutations. Give n="); read(n); writeln; A:=array[1..n] of integer; m:=1; F; end */ #include "rsdata.h" extern int IC; /* global control */ extern int modulenumber; /* module number */ extern unsigned int *DISPVIRT,*DISPDIR; /* displays' addresses */ extern unsigned int *lastcor,*mycoroutine,*myprocess; extern unsigned int *current,*local,*global; #define numprot 3 int displ= 5; int displdir = 9; int curr= 11; int lstcor= 13; int chead =15; int offnum = 1; int protnum= numprot; int perm [] = { 0,0,1}; int perminv [] = { 0,0,1}; struct Prototype PROT [] = /* kind num lspn rspan ref dcl lev lst pmdd Sl DL Lsc Stat hand pref pslen*/ { {2, 0, 0, 27, 0, -1, 0, 0, 0, 27, 26, 25, 24, -1, -1, 1}, {1, 1, 0, 9, 1, 0, 1, 0, 1, 9, 8, 7, 6, -1, -1, 1}, {6, 2, 1} }; int (* module [numprot]) (); jmp_buf buffer; struct Offsets OFF[]= { 0, 28, 0, 9, 0, 0, 0, 0, 10, 1, 2, 0, 9, 0 }; struct Elem EL[]= { 3, 1, 0, 5, 2, 0, 7, 3, 0, 11, 4, 0, 13, 5, 0, 15, 6, 0, 17, 7, 0, 26, 8, 1, 27, -1,2, 8, 10, 1, 9, -1, 2 }; struct Hlstelem HL[]= { 0 }; struct Sgelem SL[]= { 0 }; int pawel() { switch (IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: printf("Generation of all permutations. Give n="); scanf("%d",Global(1)); printf(" \n"); Openarray(2,1,*Global(1),Global(3)); { int i; for (i=1; i<= *Global(1); i++) *Arrayelem(Global(3),i)=0; }; *Global(2)=1; Dopen(1,0,Global(17)); IC=2; Go(Global(17)); L2: Killafter(); Endrun(); } int F() { switch (IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: if (*Global(2)== *Global(1)+1) { int i; for (i=1; i<= *Global(1); i++) printf("%d ",*(Arrayelem(Global(3),i))); printf(" \n"); } else {int i; for (i=1; i<= *Global(1);i++) { if (*(Arrayelem(Global(3),i))==0) { *(Arrayelem(Global(3),i))= *Global(2); (*Global(2))++; Dopen(1,0,Global(17)); *Local(1)=i; IC=2; Go(Global(17)); L2: Killafter(); (*Global(2))--; i= *Local(1); *(Arrayelem(Global(3),i))=0; }; }; }; Back(); } main () { Init(); module[0]=pawel; module[1]=F; IC=1; modulenumber=0; if (setjmp(buffer) !=-2) module[modulenumber](); } /* program square; var a,b,c,delta,x1,x2:real; begin writeln(" solution of square equation a*x**2 b*x +c=0"); write(" give a= "); read(a); write(" give b= "); read(b); write(" give c= "); read(c); delta:=b**2 - 4*a*c; if delta < 0 then writeln(" no solutions"); endrun; fi; delta:=sqrt(delta); x1:=(-b-delta)/2/a; x2:=(-b+delta)/2/a; writeln("x1=",x1,"x2=",x2); end */ #include #include "rsdata.h" extern int IC; /* global control */ extern int modulenumber; /* module number */ extern unsigned int *DISPVIRT,*DISPDIR; /* displays' addresses */ extern unsigned int *lastcor,*mycoroutine,*myprocess; extern unsigned int *current,*local,*global; #define numprot 1 #define rlh sizeof(float)/sizeof(int) #define aoff 1 #define boff 1+rlh #define coff 1+2*rlh #define deloff 1+3*rlh #define x1off 1+4*rlh #define x2off 1+5*rlh int displ=15; int displdir =17; int curr= 18; int lstcor= 20; int chead =22; int offnum = 1; int protnum= numprot; int perm [] = { 0,0,1}; int perminv [] = { 0,0,1}; struct Prototype PROT [] = /* kind num lspn rspan ref dcl lev lst pmdd Sl DL Lsc Stat hand pref pslen*/ { {2, 0, 0, 27, 0, -1, 0, 0, 0, 27, 26, 25, 24, -1, -1, 1} }; int (* module [numprot+1]) () ; jmp_buf buffer; struct Offsets OFF[]= { 0, 28, 0, 6, 0, 0, 0 }; struct Elem EL[]= { 15, 1, 0, 18, 2, 0, 20, 3, 0, 22, 4, 0, 26, 5, 1, 27, -1,2, }; struct Hlstelem HL[]= { 0 }; struct Sgelem SL[]= { 0 }; int square() { switch (IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: printf(" solution of square equation a*x**2 + b*x +c=0\n"); printf(" \ngive a="); scanf("%f", Flglobal(aoff)); printf(" \ngive b="); scanf("%f", Flglobal(boff)); printf(" \ngive c="); scanf("%f", Flglobal(coff)); * Flglobal(deloff) = (* Flglobal(boff))*(* Flglobal(boff))- 4*(* Flglobal(aoff))*(* Flglobal(coff)); if ( * Flglobal(deloff) < 0 ) { printf(" no solutions\n"); Endrun(); }; * Flglobal(deloff) = sqrt( (double) * Flglobal(deloff) ); * Flglobal(x1off) = (- * Flglobal(boff) - * Flglobal(deloff))/2/ * Flglobal(aoff); * Flglobal(x2off) = (- * Flglobal(boff) + * Flglobal(deloff))/2/ * Flglobal(aoff); printf(" \n x1=%f\n",* Flglobal(x1off)); printf(" \n x2=%f\n",* Flglobal(x2off)); L2: Endrun(); } main () { Init(); module[0]=square; IC=1; IC=1; modulenumber=0; if (setjmp(buffer) !=-2) module[modulenumber](); } /* program functest; type F: function(n:integer): integer; unit f : function(n:integer):F; unit h:F; begin result:=n*2; end h; unit g:F; begin result:=n+2; end g; begin if n=0 then result=h else result:=g fi; end f; var x,y :F; n:integer; begin x:=f(0); y:=f(1); write("n="); readln(n); writeln(x(n)); write("m="); readln(n); writeln(y(n)); end */ #include "rsdata.h" extern int IC; /* global control */ extern int modulenumber; /* module number */ extern unsigned int *DISPLAY,*DISPDIR; /* displays' addresses */ extern unsigned int *lastcor,*mycoroutine,*myprocess; extern unsigned int *current,*local,*global; #define numprot 4 int displ= -9; int displdir = 20; int curr= -11; int lstcor= -13; int chead = -15; int protnum=numprot; int offnum=3; int perm [] = { 0,1,2}; int perminv [] = { 0,1,2}; struct Prototype PROT [] = /* kind num lspn rspan ref dcl lev lst pmdd Sl DL Lsc Stat hand pref pslen */ { {2, 0, 15, 27, 0, -1, 0, 0, 0, 27, 26, 25, 24, -1, -1, 1}, {1, 1, 0, 9, 1, 0, 1, 0, 0, 9, 8, 7, 6, -1, -1, 1}, {1, 2, 0, 9, 2, 1, 2, 0, 0, 9, 8, 7, 6, -1, -1, 1}, {1, 3, 0, 9, 2, 1, 2, 0, 0, 9, 8, 7, 6, -1, -1, 1} }; int (* module [numprot]) () ; jmp_buf buffer; struct Offsets OFF[]= { 0, 43, 0, 11, 0, 0, 0, 0, 10, 1, 3, 0, 11, 0, 0, 10, 2, 2, 0, 14, 0, }; struct Elem EL[]= { 7, 1, 2, 9, 2, 2, 16, 3, 0, -9, 4, 0, -7, 5, 0, -5, 6, 0, -11, 7, 0, -13, 8, 0, -15, 9, 0, 26, 10, 1, 27, -1, 2, 2, 12, 2, 8, 13, 1, 9, -1, 2, 8, 15, 1, 9, -1, 2 }; struct Hlstelem HL[]= { 0 }; struct Sgelem SL[]= { 0 }; procclostest() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; case 5: goto L5; break; }; L1: Dopen(1,0,Global(16)); *(Physical(Global(16))+1)= 0; IC=2;Go(Global(16)); L2: Procclosmove(Global(7), Physical(Global(16))+2); Killafter(); Dopen(1,0,Global(16)); *(Physical(Global(16))+1)= 1; IC=3;Go(Global(16)); L3: Procclosmove(Global(9), Physical(Global(16))+2); Killafter(); printf("n="); scanf("%d",Global(6)); Slopen(*Global(8),Global(16),Global(7)); *(Physical(Global(16))+1)= *Global(6); IC=4;Go(Global(16)); L4: printf("%d\n",*(Physical(Global(16))+2)); Killafter(); printf("m="); scanf("%d",Global(6)); Slopen(*Global(10),Global(16),Global(9)); *(Physical(Global(16))+1)= *Global(6); IC=5;Go(Global(16)); L5: printf("%d\n",*(Physical(Global(16))+2)); Killafter(); Endrun(); } f() { if ( *Local(1) == 0) { *Local(2) = *current; *Local(3) = 2; } else { *Local(2) = *current; *Local(3) = 3; }; Back(); } h() { *Local(2) = *Local(1) * 2; Back(); } g() { *Local(2) = *Local(1) +2; Back(); } main () { Init(); module[0]=procclostest; module[1]=f; module[2]=h; module[3]=g; IC=1; modulenumber=0; if (setjmp(buffer)!=-2) module[modulenumber](); } /* program MEMORYTEST; var i,j,k,n: integer, X,Y: A, Z: arrayof A; unit A: class; var P: arrayof A; begin array P dim(1:j); end A; begin i:=0; read(n); read(k); for j:=1 to n do X:=new A; i:=i+1; if i=k then Z:=Y.P; kill(Y); kill(Z); i:=0; fi; Y:=X; od; end */ #include "rsdata.h" extern int IC; /* global control */ extern int modulenumber; /* module number */ extern unsigned int *DISPVIRT,*DISPDIR; /* displays' addresses */ extern unsigned int *lastcor,*mycoroutine,*myprocess; extern unsigned int *current,*local,*global; #define numprot 3 int displdir = 15; int displ= 11; int curr= 17; int lstcor= 19; int chead =21; int protnum=numprot; int offnum=1; int perm [] = { 0,0,1}; int perminv [] = { 0,0,1}; struct Prototype PROT[]= /* kind num lspn rspan ref dcl lev lst pmdd Sl DL Lsc Stat hand pref pslen */ { {2, 0, 0, 27, 0, -1, 0, 0, 0, 27, 26, 25, 24, -1, -1, 1}, {0, 1, 0, 9, 1, 0, 1, 0, 1, 9, 8, 7, 6, -1, -1, 1}, {7, 2} }; int (* module [numprot]) () ; jmp_buf buffer; struct Offsets OFF[]= { 0, 30, 0, 8, 0, 0, 0, 0, 12, 1, 3, 0, 8, 0 }; struct Elem EL[]= { 5, 1, 0, 7, 2, 0, 11, 3, 0, 13, 4, 0, 21, 5, 0, 17, 6, 0, 26, 7, 1, 27, -1,2, 1, 9, 0, 8, 10, 1, 9, -1, 2 }; struct Hlstelem HL[]= { 0 }; struct Sgelem SL[]= { 0 }; int memor() { switch (IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: *Global(1)=0; printf("\n n="); scanf("%d",Global(4)); printf("\n k="); scanf("%d",Global(3)); *Global(2)=1; while (1) { if (*Global(2) > *Global(4)) break; Dopen(1,0,Global(5)); IC=2; Go(Global(5)); L2: (*Global(1))++; if (*Global(1)== *Global(3)) { Refmove(Global(9),Physical(Global(7))+1); Gkill(Global(7)); Gkill(Global(9)); *Global(1)=0; }; Refmove(Global(7),Global(5)); (*Global(2))++; }; Endrun (); } int A() { Openarray(2,1,*Global(2),Local(1)); Endclass (); } main () { Init(); module[0]=memor; module[1]=A; IC=1; modulenumber=0; if (setjmp(buffer)!=-2) module[modulenumber](); }  /* program merge; unit node: class; var left,right : node, val : integer; unit ins: procedure( value: integer) ; begin if val > value then if left=none then left:=new node; left.val:=value; else call left.ins(value); fi; else if right = none then right:=new node; right.val:=value; else call right.ins(value) fi; fi; end ins; end node; unit traverse : coroutine (x:node); var val: integer; unit t: procedure(y:node); begin if y=/=none then call t(y.left); val:=y.val; detach; call t(y.right); fi; end t; begin return; call t(x); val:=m; end traverse; var n,i,j,min,m,k: integer, d: arrayof node, tr: arrayof traverse; begin read(n); array d dim(1:n); for i:=1 to n do read(j); write(j); if j>m then m:=j fi; d(i):=new node; d(i).val:=j; do read(j); if j=-1 then writeln; exit fi; write(j); if j>m then m:=j fi; call d(i).ins(j) od; od; m:=m+1; array tr dim (1:n); min:=0; for i:=1 to n do tr(i):=new traverse(d(i)); attach(tr(i)); od; k:=0; do if min=m then exit fi; min:=tr(1).val; j:=1; for i:=2 to n do if min > tr(i).val then min:=tr(i).val; j:=i fi; od; if min *Local(1)) { if (Notmember(Address(1,1))) { Dopen(1,0,Address(1,1)); IC=2; Go(Address(1,1)); L2: *(Physical(Address(1,1))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,1)); *(Physical(Local(2))+1)= *Local(1); IC=3; Go(Local(2)); L3: Killafter() ; }; } else { if (Notmember(Address(1,3))) { Dopen(1,0,Address(1,3)); IC=4; Go(Address(1,3)); L4: *(Physical(Address(1,3))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,3)); *(Physical(Local(2))+1)= *Local(1); IC=5; Go(Local(2)); L5: Killafter(); }; }; Back(); } traverse() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: IC=2; Back(); L2: Dopen(4,3,Local(4)); Refmove(Physical(Local(4))+1,Local(1)); IC=3; Go(Local(4)); L3: Killafter(); *Local(3)= *Global(5); IC=4; Attach(lastcor); L4: Endcor(); } t() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: if (Member(Local(1))) { Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+1); IC=2; Go(Local(3)); L2: Killafter(); *Address(1,3)= *(Physical(Local(1))+5); IC=3; Attach(lastcor); L3: Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+3); IC=4; Go(Local(3)); L4: Killafter(); }; Back(); } merge() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; case 5: goto L5; break; case 6: goto L6; break; }; L1: printf("Number of trees n="); scanf("%d",Global(1)); Openarray(5,1,*Global(1),Global(7)); printf("Give the values of nodes. End each tree with -1\n"); *Global(2)=1; while (1) { if (*Global(2)> *Global(1)) break; scanf("%d",Global(3)); if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Dopen(1,0,Arrayelem(Global(7),*Global(2))); IC=2; Go(Arrayelem(Global(7),*Global(2))); L2: *(Physical(Arrayelem(Global(7),*Global(2)))+5)= *Global(3); while(1) { scanf("%d",Global(3)); if (*Global(3) == -1) break; if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Slopen(2,Global(16),Arrayelem(Global(7),*Global(2))); *(Physical(Global(16))+1)= *Global(3); IC=3; Go(Global(16)); L3: Killafter(); }; (*Global(2))++; }; (*Global(5))++; Openarray(5,1,*Global(1),Global(9)); *Global(4)=0; *Global(2)=1; while(1) { if (*Global(2) > *Global(1)) break; Dopen(3,0,Arrayelem(Global(9),*Global(2))); Refmove(Physical(Arrayelem(Global(9),*Global(2)))+1, Arrayelem(Global(7),*Global(2))); IC=4; Go(Arrayelem(Global(9),*Global(2))); L4: IC=5; Attach(Arrayelem(Global(9),*Global(2))); L5: (*Global(2))++; }; *Global(6)=0; while(1) { if (*Global(4) == *Global(5) ) break; *Global(4)= *(Physical(Arrayelem(Global(9),1))+3); *Global(3)=1; *Global(2)=2; while (1) { if (*Global(2) > *Global(1)) break; if (*Global(4) > *(Physical(Arrayelem(Global(9),*Global(2)))+3)) { *Global(4) = *(Physical(Arrayelem(Global(9),*Global(2)))+3); *Global(3)= *Global(2); }; (*Global(2))++; }; if (*Global(4) < *Global(5)) { printf("%d ",*Global(4)); IC=6; Attach(Arrayelem(Global(9),*Global(3))); L6: (*Global(6))++; if (*Global(6)==10) { printf(" \n"); *Global(6)=0; }; }; }; Attach(Arrayelem(Global(9),*Global(3))); Endrun(); } main () { Init(); module[0]=merge; module[1]=node; module[2]=ins; module[3]=traverse; module[4]=t; IC=1; if (setjmp(buffer)!=-2) module[modulenumber](); }  /* program merge; unit node: class; var left,right : node, val : integer; unit ins: procedure( value: integer) ; begin if val > value then if left=none then left:=new node; left.val:=value; else call left.ins(value); fi; else if right = none then right:=new node; right.val:=value; else call right.ins(value) fi; fi; end ins; end node; unit traverse : coroutine (x:node); var val: integer; unit t: procedure(y:node); begin if y=/=none then call t(y.left); val:=y.val; detach; call t(y.right); fi; end t; begin return; call t(x); val:=m; end traverse; unit killtree: procedure (x:node); begin if x=/= none then killtree(x.left); killtree(x.right); kill(x); fi; end killtree; unit clear:procedure ; var i:integer; begin for i:=1 to n do call killtree(d(i)); od; for i:=1 to n do kill(tr(i)); od; kill(d); kill(tr); end clear; var n,i,j,min,m,k: integer, d: arrayof node, tr: arrayof traverse; begin read(n); array d dim(1:n); for i:=1 to n do read(j); write(j); if j>m then m:=j fi; d(i):=new node; d(i).val:=j; do read(j); if j=-1 then writeln; exit fi; write(j); if j>m then m:=j fi; call d(i).ins(j) od; od; m:=m+1; array tr dim (1:n); min:=0; for i:=1 to n do tr(i):=new traverse(d(i)); attach(tr(i)); od; k:=0; do if min=m then exit fi; min:=tr(1).val; j:=1; for i:=2 to n do if min > tr(i).val then min:=tr(i).val; j:=i fi; od; if min *Local(1)) { if (Notmember(Address(1,1))) { Dopen(1,0,Address(1,1)); IC=2; Go(Address(1,1)); L2: *(Physical(Address(1,1))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,1)); *(Physical(Local(2))+1)= *Local(1); IC=3; Go(Local(2)); L3: Killafter() ; }; } else { if (Notmember(Address(1,3))) { Dopen(1,0,Address(1,3)); IC=4; Go(Address(1,3)); L4: *(Physical(Address(1,3))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,3)); *(Physical(Local(2))+1)= *Local(1); IC=5; Go(Local(2)); L5: Killafter(); }; }; Back(); } traverse() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: IC=2; Back(); L2: Dopen(4,3,Local(4)); Refmove(Physical(Local(4))+1,Local(1)); IC=3; Go(Local(4)); L3: Killafter(); *Local(3)= *Global(5); IC=4; Attach(lastcor); L4: Endcor(); } t() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: if (Member(Local(1))) { Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+1); IC=2; Go(Local(3)); L2: Killafter(); *Address(1,3)= *(Physical(Local(1))+5); IC=3; Attach(lastcor); L3: Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+3); IC=4; Go(Local(3)); L4: Killafter(); }; Back(); } clear() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1:*Local(1)=1; while (1) { if (*Local(1)> *Global(1)) break; Dopen(7,0,Local(2)); Refmove(Physical(Local(2))+1,Arrayelem(Global(7),*Local(1))); IC=2; Go(Local(2)); L2: Killafter(); (*Local(1))++; }; Memorydump(); *Local(1)=1; while (1) { if (*Local(1)> *Global(1)) break; Gkill(Arrayelem(Global(9),*Local(1))); (*Local(1))++; }; Memorydump(); Gkill(Global(7)); Gkill(Global(9)); Back(); } killtree() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; }; L1:if (Member(Local(1))) { Dopen(7,0,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+1); IC=2; Go(Local(3)); L2: Killafter(); Dopen(7,0,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+3); IC=3; Go(Local(3)); L3: Killafter(); Gkill(Local(1)); }; Back(); } merge() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; case 5: goto L5; break; case 6: goto L6; break; case 7: goto L7; break; }; L1: printf("Number of trees n="); scanf("%d",Global(1)); Openarray(5,1,*Global(1),Global(7)); printf("Give the values of nodes. End each tree with -1\n"); *Global(2)=1; while (1) { if (*Global(2)> *Global(1)) break; scanf("%d",Global(3)); if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Dopen(1,0,Arrayelem(Global(7),*Global(2))); IC=2; Go(Arrayelem(Global(7),*Global(2))); L2: *(Physical(Arrayelem(Global(7),*Global(2)))+5)= *Global(3); while(1) { scanf("%d",Global(3)); if (*Global(3) == -1) break; if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Slopen(2,Global(16),Arrayelem(Global(7),*Global(2))); *(Physical(Global(16))+1)= *Global(3); IC=3; Go(Global(16)); L3: Killafter(); }; (*Global(2))++; }; (*Global(5))++; Openarray(5,1,*Global(1),Global(9)); *Global(4)=0; *Global(2)=1; while(1) { if (*Global(2) > *Global(1)) break; Dopen(3,0,Arrayelem(Global(9),*Global(2))); Refmove(Physical(Arrayelem(Global(9),*Global(2)))+1, Arrayelem(Global(7),*Global(2))); IC=4; Go(Arrayelem(Global(9),*Global(2))); L4: IC=5; Attach(Arrayelem(Global(9),*Global(2))); L5: (*Global(2))++; }; *Global(6)=0; while(1) { if (*Global(4) == *Global(5) ) break; *Global(4)= *(Physical(Arrayelem(Global(9),1))+3); *Global(3)=1; *Global(2)=2; while (1) { if (*Global(2) > *Global(1)) break; if (*Global(4) > *(Physical(Arrayelem(Global(9),*Global(2)))+3)) { *Global(4) = *(Physical(Arrayelem(Global(9),*Global(2)))+3); *Global(3)= *Global(2); }; (*Global(2))++; }; if (*Global(4) < *Global(5)) { printf("%d ",*Global(4)); IC=6; Attach(Arrayelem(Global(9),*Global(3))); L6: (*Global(6))++; if (*Global(6)==10) { printf(" \n"); *Global(6)=0; }; }; }; Memorydump(); Dopen(6,0,Global(16)); IC=7; Go(Global(16)); L7: Killafter(); Memorydump(); Endrun(); } main () { Init(); module[0]=merge; module[1]=node; module[2]=ins; module[3]=traverse; module[4]=t; module[6]=clear; module[7]=killtree; IC=1; if (setjmp(buffer)!=-2) module[modulenumber](); } /* program merge; unit node: class; var left,right : node, val : integer; unit ins: procedure( value: integer) ; begin if val > value then if left=none then left:=new node; left.val:=value; else call left.ins(value); fi; else if right = none then right:=new node; right.val:=value; else call right.ins(value) fi; fi; end ins; end node; unit traverse : coroutine (x:node); var val: integer; unit t: procedure(y:node); begin if y=/=none then call t(y.left); val:=y.val; detach; call t(y.right); fi; end t; begin return; call t(x); val:=m; end traverse; var n,i,j,min,m,k: integer, d: arrayof node, tr: arrayof traverse; begin read(n); array d dim(1:n); for i:=1 to n do read(j); write(j); if j>m then m:=j fi; d(i):=new node; d(i).val:=j; do read(j); if j=-1 then writeln; exit fi; write(j); if j>m then m:=j fi; call d(i).ins(j) od; od; m:=m+1; array tr dim (1:n); min:=0; for i:=1 to n do tr(i):=new traverse(d(i)); attach(tr(i)); od; k:=0; do if min=m then exit fi; min:=tr(1).val; j:=1; for i:=2 to n do if min > tr(i).val then min:=tr(i).val; j:=i fi; od; if min *Local(1)) { if (Notmember(Address(1,1))) { Dopen(1,0,Address(1,1)); IC=2; Go(Address(1,1)); L2: *(Physical(Address(1,1))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,1)); *(Physical(Local(2))+1)= *Local(1); IC=3; Go(Local(2)); L3: Killafter() ; }; } else { if (Notmember(Address(1,3))) { Dopen(1,0,Address(1,3)); IC=4; Go(Address(1,3)); L4: *(Physical(Address(1,3))+5)= *Local(1); } else { Slopen(2,Local(2),Address(1,3)); *(Physical(Local(2))+1)= *Local(1); IC=5; Go(Local(2)); L5: Killafter(); }; }; Back(); } traverse() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: IC=2; Back(); L2: Dopen(4,3,Local(4)); Refmove(Physical(Local(4))+1,Local(1)); IC=3; Go(Local(4)); L3: Killafter(); *Local(3)= *Global(5); IC=4; Attach(lastcor); L4: Endcor(); } t() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; }; L1: if (Member(Local(1))) { Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+1); IC=2; Go(Local(3)); L2: Killafter(); *Address(1,3)= *(Physical(Local(1))+5); IC=3; Attach(lastcor); L3: Dopen(4,3,Local(3)); Refmove(Physical(Local(3))+1,Physical(Local(1))+3); IC=4; Go(Local(3)); L4: Killafter(); }; Back(); } merge() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; case 4: goto L4; break; case 5: goto L5; break; case 6: goto L6; break; }; L1: printf("Number of trees n="); scanf("%d",Global(1)); Openarray(5,1,*Global(1),Global(7)); printf("Give the values of nodes. End each tree with -1\n"); *Global(2)=1; while (1) { if (*Global(2)> *Global(1)) break; scanf("%d",Global(3)); if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Dopen(1,0,Arrayelem(Global(7),*Global(2))); IC=2; Go(Arrayelem(Global(7),*Global(2))); L2: *(Physical(Arrayelem(Global(7),*Global(2)))+5)= *Global(3); while(1) { scanf("%d",Global(3)); if (*Global(3) == -1) break; if (*Global(3) > *Global(5)) *Global(5)= *Global(3); Slopen(2,Global(16),Arrayelem(Global(7),*Global(2))); *(Physical(Global(16))+1)= *Global(3); IC=3; Go(Global(16)); L3: Killafter(); }; (*Global(2))++; }; (*Global(5))++; Openarray(5,1,*Global(1),Global(9)); *Global(4)=0; *Global(2)=1; while(1) { if (*Global(2) > *Global(1)) break; Dopen(3,0,Arrayelem(Global(9),*Global(2))); Refmove(Physical(Arrayelem(Global(9),*Global(2)))+1, Arrayelem(Global(7),*Global(2))); IC=4; Go(Arrayelem(Global(9),*Global(2))); L4: IC=5; Attach(Arrayelem(Global(9),*Global(2))); L5: (*Global(2))++; }; *Global(6)=0; while(1) { if (*Global(4) == *Global(5) ) break; *Global(4)= *(Physical(Arrayelem(Global(9),1))+3); *Global(3)=1; *Global(2)=2; while (1) { if (*Global(2) > *Global(1)) break; if (*Global(4) > *(Physical(Arrayelem(Global(9),*Global(2)))+3)) { *Global(4) = *(Physical(Arrayelem(Global(9),*Global(2)))+3); *Global(3)= *Global(2); }; (*Global(2))++; }; if (*Global(4) < *Global(5)) { printf("%d ",*Global(4)); IC=6; Attach(Arrayelem(Global(9),*Global(3))); L6: (*Global(6))++; if (*Global(6)==10) { printf(" \n"); *Global(6)=0; }; }; }; Endrun(); } main () { Init(); module[0]=merge; module[1]=node; module[2]=ins; module[3]=traverse; module[4]=t; modulenumber=0; IC=1; if (setjmp(buffer)!=-2) module[modulenumber](); }  #include "rsdata.h" extern int IC; /* global control */ extern int modulenumber; /* module number */ extern unsigned int *DISPLAY,*DISPDIR; /* displays' addresses */ extern unsigned int *lastcor,*mycoroutine,*myprocess; extern unsigned int *current,*local,*global; #define numprot 5 int displ= -9; int displdir = 20; int curr= -11; int lstcor= -13; int chead = -15; int protnum=numprot; int offnum=4; int perm [] = { 0,1,0,2,1,3}; int perminv [] = { 0,1,0,2,1,3}; struct Prototype PROT [] = /* kind num lspn rspan ref dcl lev lst pmdd Sl DL Lsc Stat hand pref pslen */ { {2, 0, 15, 27, 0, -1, 0, 0, 0, 27, 26, 25, 24, -1, -1, 1}, {0, 1, 0, 9, 1, 0, 1, 0, 0, 9, 8, 7, 6, -1, -1, 1}, {1, 2, 0, 9, 1, 0, 1, 0, 0, 9, 8, 7, 6, -1, -1, 1}, {0, 3, 0, 9, 1, 2, 2, 0, 2, 9, 8, 7, 6, -1, 1, 2}, {1, 4, 0, 9, 1, 3, 3, 0, 2, 9, 8, 7, 6, -1, -1, 1} }; int (* module [numprot]) () ; jmp_buf buffer; struct Offsets OFF[]= { 0, 43, 0, 11, 0, 0, 0, 0, 10, 1, 2, 0, 11, 0, 0, 10, 2, 3, 0, 13, 0, 0, 10, 3, 4, 0, 16, 0, 0, 10, 4, 4, 0, 20, 0 }; struct Elem EL[]= { 7, 1, 0, 9, 2, 0, 16, 3, 0, -9, 4, 0, -7, 5, 0, -5, 6, 0, -11, 7, 0, -13, 8, 0, -15, 9, 0, 26, 10, 1, 27, -1, 2, 8, 12, 1, 9, -1, 2, 2, 14, 0, 8, 15, 1, 9, -1, 2, 1, 17, 0, 4, 18, 0, 8, 19, 1, 9, -1, 2, 1, 21, 0, 3, 22, 0, 8, 23, 1, 9, -1, 2}; struct Hlstelem HL[]= { 0 }; struct Sgelem SL[]= { 0 }; sltest() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; case 3: goto L3; break; }; L1: Dopen(2,0,Global(16)); IC=2;Go(Global(16)); L2: Killafter(); Slopen(4,Global(16),Global(7)); IC=3; Go(Global(16)); L3: Killafter(); Endrun(); } A() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: Inn(1); L2: Endclass(); } Bk() { switch(IC) { case 1: goto L1; break; case 2: goto L2; break; }; L1: Dopen(3,2,Global(7)); IC=2; Go(Global(7)); L2: Back(); } B() { IC=2; modulenumber=1; longjmp(buffer,-1); } P() { (* Address(2,1))++; printf("i=%d\n", *Address(2,1)); Back(); } main () { Init(); module[0]=sltest; module[1]=A; module[2]=Bk; module[3]=B; module[4]=P; IC=1; modulenumber=0; if (setjmp(buffer)!=-2) module[modulenumber](); }