*
Xiaoming just on primary school, learned the first poker "magic", everywhere to show people. The Magic's content is this:
he holds a stack of cards in his hand: A, 2, ... J,q,k altogether 13. He first carefully designed their own order, and then face down and hold, to start the performance.
He first took one from the bottom and put it on top, and take one from the bottom. Open the table, is a, and then from the bottom of the top, and then from the bottom of the open table, is 2;
So circulate until the hand has only a card, turn open the table, just is K. At
this time, the order of the table card is: a,2,3,4,5,6,7,8,9,10,j,q,k
please calculate, Xiao Ming at the beginning of the hand in the order of the cards.
write the results, comma split, xiaoming "Magic" at the beginning, the bottom of the card output as the first data.
* *
#include "stdio.h"
#include "string.h"
int main ()
{
int i,index,temp;
int a[13];
memset (A,0,sizeof (a)); Initialization array is 0 for
(i=1,index=1;i<14;i++) {while
(1) {
if (a[index]==0) {
a[index]=i;break
} else index++;
}
Temp=0;
while (1) {
index++;
index=index%13;
if (a[index]==0) temp++;
if (temp==2 | | i==13) break;
}
for (i=0;i<13;i++)
{ if (a[i]<=10) printf ("%d", A[i]);
else if (a[i]==11) printf ("J");
else if (a[i]==12) printf ("Q");
else printf ("K");
}
printf ("\ n");
return 0;
}