您的位置:首页 > 其它

第15周项目2:洗牌

2016-06-07 19:06 197 查看
/*

* Copyright(c)2016,烟台大学计算机与控制工程学院

* All rights reserved.

* 文件名称:第15周项目2:洗牌

* 作者:马康泰

* 完成日期:2016.6.7

*

* 问题描述:在扑克牌游戏中,每次游戏开始都要求把54张牌重新排序一下,称为洗牌。试编写一段程序将一副扑克牌(1~54)随机洗好,顺序输出54张牌的情况

* 输入描述:

* 程序输出:

*/
#include <iostream>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define MAX 55
int main(int argc, char* argv[])
{
srand( (unsigned)time( NULL ) );

int i,n;
int a[54];
cout << "洗牌前:"<< endl;
for(i=1;i<55;i++)
{
cout << i<<" ";
}
cout <<endl;
cout<< "洗牌后:"<<endl;
for(i=1;i<55;i++)
{
a[i]=rand()%55;
for(n=1;n<55;n++)
{
if(a[i]==0)
continue;
if(a[i]==a
)
continue;
else
{
cout << a[i]<<" ";
break;
}
}

}
return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: