扑克牌洗牌程序程序不需要任何输入,启动后,将一副扑克牌(54张)随机洗牌后输出,然后退出程序.各种牌型英文为:黑桃:spade,红心:hearts,草花:flower,方块:diamonds,现取其首字母S、H、F、D
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 05:20:47
扑克牌洗牌程序程序不需要任何输入,启动后,将一副扑克牌(54张)随机洗牌后输出,然后退出程序.各种牌型英文为:黑桃:spade,红心:hearts,草花:flower,方块:diamonds,现取其首字母S、H、F、D
扑克牌洗牌程序
程序不需要任何输入,启动后,将一副扑克牌(54张)随机洗牌后输出,然后退出程序.
各种牌型英文为:
黑桃:spade,红心:hearts,草花:flower,方块:diamonds,
现取其首字母S、H、F、D分别代表这4种牌型,并与2、3、4、5、6、7、8、9、10、J、Q、K、A这13种点数搭配成52张牌,再加上King(大王)、Tetrarch(小王),构成54张牌.
要求输出格式为每行4张牌,例:
S2,SK,DJ,D9
Tetrarch,King,DA,F3
….
F2,F4
扑克牌洗牌程序程序不需要任何输入,启动后,将一副扑克牌(54张)随机洗牌后输出,然后退出程序.各种牌型英文为:黑桃:spade,红心:hearts,草花:flower,方块:diamonds,现取其首字母S、H、F、D
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
int main()
{
//黑桃:spade,红心:hearts,草花:flower,方块:diamonds
//King(大王)、Tetrarch(小王)
//2、3、4、5、6、7、8、9、10、J、Q、K、A
char * poker[54] = {"S2","S3","S4","S5","S6","S7","S8","S9","S10","SJ","SQ","SK","SA",
"H2","H3","H4","H5","H6","H7","H8","H9","H10","HJ","HQ","HK","HA",
"F2","F3","F4","F5","F6","F7","F8","F9","F10","FJ","FQ","FK","FA",
"D2","D3","D4","D5","D6","D7","D8","D9","D10","DJ","DQ","DK","DA",
"Tetrarch","King"};
int num[54];
//获取随机数 存储至数组num中
int i = 0;
//使用当前时间作为随机数种子来获取真正的随机数
time_t t;
srand((unsigned) time(&t));
while (1)
{
int temp = rand()%54;
int ret=0;
for (int j=0;j