#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define MAX 18
int xipai(int);
void fapai(int);
int type_j(int);
int main()
{
char* player[3];
unsigned pai = 54;
int i, p, j;
for (i = 0; i < 3; i++)
{
printf("请输入%d号玩家的ID:", i + 1);
scanf_s("%s",player[1]);
}
for (i = 0; i < 3; i++)
{
printf("%s", player[i]);
for (j = 0; j < MAX; j++)
{
p = xipai(pai);
putchar('\b');
fapai(p);
}
printf("\n");
}
}
int xipai(int pai)
{
int p;
time_t t;
srand((unsigned)time(&t));
p = rand() % pai - 1;
p++;
return p;
}
//判断,可跳过
void fapai(int p)
{
char* type = NULL;
if (p <= 10) type = "方";
else if (p <= 20)
{
type = "梅";
p = p % 10;
}
else if (p <= 30)
{
type = "红";
p = p % 20;
}
else if (p <= 40)
{
type = "黑";
p = p % 30;
}
else if (p <= 43)
{
type = "方";
type_j(p);
}
else if (p <= 46)
{
type = "梅";
type_j(p);
}
else if (p <= 49)
{
type = "红";
type_j(p);
}
else if (p <= 52)
{
type = "黑";
type_j(p);
}
else if (p == 53)
{
printf("小王");
return;
}
else if (p == 54)
{
printf("大王");
return;
}
printf("%s", type);
printf("%c", p + 48);
}
int type_j(int p)
{
p = p % 40;
switch (p % 3)
{
case 1:return 81 - 48;
case 2:return 75 - 48;
case 0:return 74 - 48;
}
}
|