-
-
Save GZShi/3803759 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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