1 ImportJava.util.Scanner; 2 3 Public classpukepai{4 int[] A=New int[1000];5 int[] b=New int[1000];6 intAleft,aright,bleft,bright;7 int[] s=New int[100];8 int[] t=New int[9];9 inttop;Ten intFlag; One A Public Static voidMain (string[] args) { -Pukepai px=NewPukepai (); - px.go (); the } - Public voidGo () { - Getnum (a); - Look (a); + Getnum (b); - Look (b); +Aright=5;bright=5; A intTopp; at while((aleft<aright) && (bleft<Bright)) { - if(s[top]==0){ -s[top]=A[aleft]; -T[a[aleft]]=1; -aleft++; -}Else{ in if(t[a[aleft]]==1){ - for(intj=top;j>=0;j--){ to if(s[j]==A[aleft]) { +flag=J; - Break; the } * } $topp=top;Panax Notoginseng for(intj=flag;j<=topp;j++){ -aright++; thea[aright]=S[j]; +T[s[j]]=0; AS[j]=0; the if(top>0) {top--;} + if(j==top) { -aright++; $a[aright]=A[aleft]; $aleft++; - } - } the}Else{ -s[++top]=A[aleft];WuyiT[a[aleft]]=1; thealeft++; - } Wu } - Look (s), look (a); About if(s[top]==0){ $s[top]=B[bleft]; -T[b[bleft]]=1; -bleft++; -}Else{ A if(t[b[bleft]]==1){ + for(intj=top;j>=0;j--){ the if(s[j]==B[bleft]) { -flag=K; $ Break; the } the } thetopp=top; the for(intj=flag;j<=topp;j++){ -bright++; inb[bright]=S[j]; theT[s[j]]=0; theS[j]=0; About if(top>0) {top--;} the if(j==top) { thebright++; theb[bright]=B[bleft]; +bleft++; - } the }Bayi}Else{ thes[++top]=B[bleft]; theT[b[bleft]]=1; -bleft++; - } the } the Look (s); the } the } - Public int[] Getnum (int[] a) { theScanner Scanner =NewScanner (system.in); the for(inti=0;i<6;i++){ thea[i]=scanner.nextint ();94 } the returnA; the } the Public voidLookint[] a) {98System.out.println (""); About for(inti=0;i<9;i++){ - System.out.print (A[i]);101 }102 }103}
"Connect Bamboo" card game Java Implementation results