c语言中如何打出草花图案,如何用c语言编写纸牌发牌程序

发牌原程序见我的空间(http://hi.baidu.com/crazycola/blog/item/52402bd4b3f68705a08bb746.html),可选是否包含大小王,可选发牌列数。

以下为改过的版本,不包含大小王(即总数52张),只能发4堆。

另外附加了用户菜单,原程序中不含菜单部分。

代码如下:

---------------------------------------

#include

#include

#include

int menu()

{

int choice;

printf("1 发牌/0 退出:");

scanf("%d",&choice);

return choice;

}

void main( void )

{

int i1, j, total;

int *iArr;

int tag = 0;

char* pok_C[] = { "黑桃", "红桃", "梅花", "方块" };

char* pok_N[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };

if(!menu()) exit(0);

total = 52;

srand( (unsigned)time( NULL ) );

iArr = (int*)malloc(total*sizeof(int));

for( i1=0; i1

{

iArr[i1]=rand()%total;

if( i1==0 ) continue;

do {

tag = 0;

for( j=0; j

if( iArr[j] == iArr[i1] )

{

iArr[i1]=rand()%total;

tag = 1;

}

} while( tag==1 );

}

for( i1=0; i1

{

printf("%s%s\t",pok_C[iArr[i1]%4],pok_N[iArr[i1]%13]);

if(i1%4==3) printf("\n");

}

free(iArr);

}

温馨提示:答案为网友推荐,仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值