public Man[] ManGroup; public Woman[] WomanGroup; publicGaleShapley(In in1,In in2){ CreateManGroup(in1); CreateWomanGroup(in2); InsertManFavor(); }
publicvoidCreateManGroup(In in){ int numMan=in.readInt(); int numWoman=in.readInt(); ManGroup=new Man[numMan];
for(int i=0;i<numMan;i++){ int manName=in.readInt(); Man man=new Man((char) manName,numWoman); for(int j=0;j<numWoman;j++){ int Num=in.readInt()-1; man.favorNum[j]=Num; } ManGroup[i]=man; } } publicvoidCreateWomanGroup(In in){ int numMan=in.readInt(); int numWoman=in.readInt(); WomanGroup=new Woman[numWoman]; for(int i=0;i<numWoman;i++){ int womanName=in.readInt(); Man[] men=new Man[numMan]; for(int j=0;j<numMan;j++){ int favorNum=in.readInt()-1; if (favorNum<0) continue; Man favorMan=ManGroup[favorNum]; men[j]=favorMan; }