UVA_10935: Throwing cards away I
来源:互联网 发布:爱神巧克力夏紫瞳h本知 编辑:程序博客网 时间:2024/05/16 11:09
注意输出格式,利用队列即可
#include <iostream>#include <queue>#include <vector>#include <cstdio>using namespace std;queue<int> rest;vector<int> discard;int main(){int n;while(~scanf("%d",&n)&&n){discard.clear();for(int i=1; i<=n; i++)rest.push(i);while(rest.size()>1){int top = rest.front(); rest.pop();discard.push_back(top);top = rest.front(); rest.pop();rest.push(top);}printf("Discarded cards:");if(discard.size()>0)printf(" %d",discard[0]);for(int i=1; i<discard.size(); i++)printf(", %d",discard[i]);putchar('\n');printf("Remaining card: %d\n",rest.front()); rest.pop();} return 0;}
0 0
- UVA_10935: Throwing cards away I
- Throwing cards away I
- Throwing cards away I
- uva:Throwing cards away I
- UVa10935 - Throwing cards away I
- UVA10935 - Throwing cards away I
- uva10935 - Throwing cards away I
- 10935 - Throwing cards away I
- UVa10935 - Throwing cards away I
- Throwing cards away I uva1594
- Throwing cards away I--队列
- Throwing cards away I UVA
- UVA-Throwing cards away I
- Throwing cards away I UVA
- UVA 10935 - Throwing cards away I
- UVA 10935 - Throwing cards away I
- UVa 10935 - Throwing cards away I STL
- uva 10935 - Throwing cards away I
- 互相关系数cross correlation-自相关系数-时间序列,图像
- iOS KVO观察数组
- QT5 学习之路27---渐变
- include""和include<>的区别
- 原装win8系统电脑崩溃问题解决
- UVA_10935: Throwing cards away I
- UVa 11292.Dragon of Loowater【贪心】【10月6】
- 使用enca
- RESTFUL API 的规范
- 用service实现音乐播放器
- 获取当前时间
- 再谈工科研究生如何做研究 (第一部分:关于研究选题)
- C++ const关键字
- c# 事件学习