2016/9/24 1000. 卡片游戏
来源:互联网 发布:淘宝返现违规吗 编辑:程序博客网 时间:2024/06/04 19:22
题目本身想要考察的应该还是链表的问题,一开始看到卡牌还想用栈来做,后面发现有插入的要求就没办法了。整个思路与链表还是挺符合的,没什么太大的问题。
#include <iostream>#include <list>using namespace std;class Card{public:Card(int n = 0){num = n;}int num;};int main(){int t;cin >> t;while (t--){int n;cin >> n;list <Card> cards;for (int i = n; i >= 1; i--){cards.push_back(Card(i));}while (cards.size() >= 2){cout << cards.back().num << " ";cards.pop_back();cards.push_front(cards.back());cards.pop_back();}cout << cards.back().num << " " << endl;}system("pause");}
0 0
- 2016/9/24 1000. 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏!!!
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- 卡片游戏
- Java static变量
- 遍历Map的四种方法
- C语言中的 . 和 -> 的区别
- C++基础笔记之五:快速排序
- Android原生Contacts——界面和数据库
- 2016/9/24 1000. 卡片游戏
- 关于display:inline-block,分享自张鑫旭-鑫空间-鑫生活[http://www.zhangxinxu.com]
- CSS实战技巧:clearfix清除浮动
- android小技术点随笔---- 各种view控件前置
- Python--第一天:谁来给我讲讲Python?
- MongoDB支持事务吗
- es ik分词
- 整数划分问题
- C++ hdu 2046 骨牌铺方格