Skip to content

Instantly share code, notes, and snippets.

@GZShi
Created September 29, 2012 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GZShi/3803759 to your computer and use it in GitHub Desktop.
Save GZShi/3803759 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void cut(char *poker, int n); // 切牌
void shuffle(char *poker); // 洗牌
int main(void)
{
char poker[9] = "23456789";
int n[3] = {0, 0, 0};
int i = 0;
scanf("%d %d %d", n, n+1, n+2);
while(i < 3)
{
cut(poker, *(n+i));
shuffle(poker);
printf("round 1: %s\n", poker);
++i;
}
return 0;
}
void cut(char *poker, int n)
{
char temp[9];
if(n<1 || n>7)
return;
strcpy(temp, poker);
temp[n] = 0;
strcpy(poker, poker + n);
strcat(poker, temp);
}
void shuffle(char *poker)
{
char temp[9] = "CL1024!!";
int i = 0;
while(i < 4)
{
temp[2*i] = poker[i];
temp[2*i + 1] = poker[i+4];
++i;
}
strcpy(poker, temp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment