在linux下用C语言编写发牌程序

xiaoxiao2021-02-28  86

getpid这个函数在Windows里面是无法使用的

#include <stdio.h>

#include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main() {     int poker,flag[55] = {0};     int i;     srand(getpid());     {        for(i = 0;i <52;i++); { poker = rand() % 52; while(1) { poker = rand() % 52; } flag[poker] = 1; if(poker >= 0 && poker <= 12) { printf("红桃 %d\n",poker + 1); } else if(poker >= 13 && poker <= 25) { printf("黑桃 %d\n",poker - 12); } else if(poker >= 26 && poker <= 38) { printf("方块 %d\n",poker - 25); } else if(poker >= 39 && poker <=51) printf("草花 %d\n",poker - 38); }     } return 0; }
转载请注明原文地址: https://www.6miu.com/read-63463.html

最新回复(0)