/** * The following code simulates a set of poker (initial sort a~k, total of 13) of the operation process. * * Operation process is: holding this set of cards in hand, from the front to take a piece to put in the back, and then take one from the front on the table, and then from the front of a piece put in the back, .... * This cycle is done until the last card is left on the table. The purpose of the code below is to find out the order of the cards on the last table. Initial arrangement if it is A,2,3...K, then the order on the last table is: * [2, 4, 6, 8, ten, Q, A, 5, 9, K, 7, 3, J] Please parse the code logic and speculate on the code at the line. * */ Public class poker arrangement { Public StaticListMovecard(List src) {if(src = =NULL) {return NULL; } List DST =NewVector (); for(;;) {if(src.size () = =0) { Break; } Src.add (Src.remove (0)); Dst.add (Src.remove (0)); }returnDst } Public Static void Main(string[] args) {List A =NewVector ();//arrays.aslist (): Returns a list of fixed sizes supported by the specified array. (Changes to the returned list are "directly written" to the array.) )A.addall (Arrays.aslist ("A","2","3","4","5","6","7","8","9","Ten","J","Q","K")); System.out.println (Movecard (a)); }}
Java Algorithms-Poker arrangement