Poker shuffle

冒泡:
bubbleSort(void* data[],int n, int (*cmpPro)(void* ,void*))
{
void *temp=NULL;
for(int i=0;i<n-1;i++)
for(int j=0;j<n-i-1;j++)
{
if(( cmpPro(data[j],data[j+1]))>1)
temp=data[j];
data[j] = data[j+1;
data[j+1] = temp;
}

}

Associated container: map multimap set multiset
unassociated container: list vector deque

What is the callback function:
callback function is a function call through a function pointer.
Callback function is not called directly by the parties to achieve the function, but by another calling party when a particular event or condition occurs, for response to the event or condition.
Shuffle playing cards
#include <time.h>
#include <stdlib.h>


int main(){
int a[4][13],d,i,j,m,num=0,b[52]={0};
srand(time(NULL));//种种子
for(i=0;i<4;i++)
{
for(j=0;j<13;j++)
{
a[i][j]=j+1;
}
}//初始化数组
for(int i=0;i<4;i++)
{
for(int j=0;j<13;j++)
printf("%d\t",a[i][j]);

}
For (; NUM <= 52 is;) // shuffling
{
D = RAND ()% 52 is; // a random number
for (m = 0; m < num; m ++) // other heavy
{// 6 num = 0
IF (B == D [m])
{
BREAK;
}
}
IF (m == NUM) // random array
{
B [NUM] = D; // the 52 to 52 different random numbers into an array
printf ( "% D **** \ n-', B [NUM]);
Switch (D / 13 is) // color printing
{
Case 0: the printf (" hearts "); BREAK;
Case. 1: the printf (" block " ); BREAK;
Case 2: the printf ( "flower"); BREAK;
Case. 3: the printf ( "spades"); BREAK;
}
NUM ++;
the printf ( "% 2D \% C", A [D / 13 is] [D 13 is%],% NUM = NUM 13 is == 0 && 0 '\ n-':!? ''); //
}

}

return 0;
}
}

Guess you like

Origin www.cnblogs.com/countryboy666/p/10964262.html