第十五周上机实践——项目2-洗牌
来源:互联网 发布:淘宝上七天无理由退货 编辑:程序博客网 时间:2024/04/27 14:51
/* *Copyright (c)2016,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:main.cpp *作 者:郭永恒 *完成日期:2016年6月8日 *版 本 号:v1.0 * *问题描述:洗牌 */ #include <iostream>#include <vector>#include <cstdlib>#include <ctime>using namespace std;void unordered(vector<int>& poker){ int psize = poker.size(),index; for(int i = 0; i < psize; ++i) { index = rand()%psize; int temp = poker[index]; poker[index] = poker[i]; poker[i] = temp; }}int main(){ int i = 0; srand(time(NULL)); vector<int> poker(54); for(int& c : poker) { ++i; c = i; } cout << " 洗牌前:" << endl; for(int& c : poker) cout << c << ends; unordered(poker); cout << endl << endl; cout << " 洗牌后:" << endl; for(int& c : poker) cout << c << ends; cout << endl; return 0;}
运行结果:
0 0
- 第十五周上机实践——项目2-洗牌
- 第十五周上机实践项目2:洗牌
- 第十五周实践项目2-洗牌
- 第十五周项目2——洗牌
- 第十五周项目2—洗牌
- 第十五周项目2—洗牌
- C++第十五周实践项目2————洗牌
- 第十五周上机实践项目——折腾二维数组
- 第十五周上机实践项目——杨辉三角
- 第十五周上机实践——项目1-程序填空
- 第十五周项目2-洗牌
- 第十五周项目2洗牌
- 第十五周项目2:洗牌
- 第十五周上机实践—项目1(2)—直接插入排序
- 第十五周上机实践—项目2—用哈希法组织关键字
- 第十五周项目 洗牌
- 第十五周上机实践项目1(2):阅读程序
- 第十五周项目-项目2-洗牌
- leetcode-Linked List Cycle II-142
- pixhawk软件环境的搭建
- 从田产变化看鲁迅家族的衰败:祖父入狱曾卖地
- 4查并集的简单应用,工程通路问题
- 【Leetcode】Add Digits
- 第十五周上机实践——项目2-洗牌
- Simple Neural Network [Preview]
- 【Leetcode】Group Anagrams
- 【转】解决XCode安装插件后插件不能使用的问题
- HDOJ 1195 Open the Lock bfs 双向bfs
- 算法学习笔记:递归
- 【Leetcode】Max Points on a Line
- Cannot find installed sources of Android API 23
- 牛客网笔试题