#include <stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int flag[52],i,n;
srand((unsigned int)time(NULL));
for(i=0;i<10;i++)
{
n=rand()%52;
while (flag[n]==1)
{
n = rand()%52;
}
flag[n] == 1;
if (n>=0 &&n<=12)
{
printf("红桃 %d\n",n+1);
}
else if (n>=13 &&n<=25)
{
printf("黑桃 %d\n",n-12);
}
else if (n>=26 &&n<=38)
{
printf("方块 %d\n",n-25);
}
else
{
printf("梅花 %d\n",n-38);
}
if ((n+1)%13==0)
{
printf("\n");
}
#include<stdlib.h>
#include<time.h>
int main()
{
int flag[52],i,n;
srand((unsigned int)time(NULL));
for(i=0;i<10;i++)
{
n=rand()%52;
while (flag[n]==1)
{
n = rand()%52;
}
flag[n] == 1;
if (n>=0 &&n<=12)
{
printf("红桃 %d\n",n+1);
}
else if (n>=13 &&n<=25)
{
printf("黑桃 %d\n",n-12);
}
else if (n>=26 &&n<=38)
{
printf("方块 %d\n",n-25);
}
else
{
printf("梅花 %d\n",n-38);
}
if ((n+1)%13==0)
{
printf("\n");
}
}
return 0;}