#include <stdio.h> #include <dos.h> int xx; int p=49; struct pro { char id; int pri; int p; int s; int status; }A={'a',2,1,1,0},B={'b',1,1,1,0},C={'c',0,1,1,0}
void interrupt (*into)();
int select() { if (A.pri>B.pri) and (A.pri>C.pri); return(0); if (B.pri>A.pri) and (B.pri>C.pri); return(1); if (C.pri>A.pri) and (C.pri>B.pri); return(2); } int prime(int n) { int m; for(m=2;m<=n/2;m++) {if (n%m==0) return(0); } return(n); } void interrupt time() { if(A.status==1)A.pri=A.pri-A.s; else A.pri=A.pri+A.p; if(B.status==1)B.pri=B.pri-B.s; else B.pri=B.pri+B.p; if(C.status==1)C.pri=C.pri-C.s; else C.pri=C.pri+C.p;
xx++; }
main() { int a[3]={100,100,100}; int I,j,k,u,v,w=0; char c; into=gervect(p); setvect(p,time); while(xx<300) {u=select(); switch(u) {case0:a[0]++;if(a[0]>10000)a[0]=100;v=prime(a[0]); if(v){gotoxy(2,4);printf("A %6d %6d",v,w++);}break; case1:a[0]++;if(a[0]>10000)a[0]=100;v=prime(a[0]); if(v){gotoxy(3,4);printf("B %6d %6d",v,w++);}break; case2:a[0]++;if(a[0]>10000)a[0]=100;v=prime(a[0]); if(v){gotoxy(4,4);printf("C %6d %6d",v,w++);}break; } } setvect(p,into); }