【习题5-3 UVA-10935】Throwing cards away I
2017-10-14 17:03
489 查看
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
用STL的queue写
【代码】
#include <bits/stdc++.h> using namespace std; queue <int> dl; vector <int> v; int n; int main() { //freopen("F:\\rush.txt", "r", stdin); while (~scanf("%d", &n) && n) { v.clear(); while (!dl.empty()) dl.pop(); for (int i = 1; i <= n; i++) dl.push(i); for (int i = 1; i <= n - 1; i++) { v.push_back(dl.front()); dl.pop(); dl.push(dl.front()); dl.pop(); } printf("Discarded cards:"); for (int i = 0; i < n - 1; i++) { printf(" %d%c", v[i], i == n - 2 ? '\n' : ','); } if (n == 1) puts(""); printf("Remaining card: %d\n", dl.front()); } return 0; }
相关文章推荐
- 习题5-3 UVA 10935 Throwing cards away I 卡片游戏
- 经典第五章 习题 5-3 UVA 10935 Throwing cards away I(队列的简单应用)
- 习题5-3 卡片游戏(Throwing cards away I, UVa 10935)
- UVa 10935 Throwing cards away I(习题5-3)
- uva-10935-Throwing cards away I
- UVa 10935 Throwing cards away I【队列】
- UVa 10935 Throwing cards away I
- UVa 10935 - Throwing cards away I
- UVa 10935 (水题) Throwing cards away I
- 卡片游戏(Throwing cards away I,UVa 10935)
- UVa 10935 Throwing cards away 1
- UVa 10935 - Throwing cards away I
- UVA 10935 Throwing cards away I
- UVA 10935 Throwing Cards Away I 卡片游戏
- Uva10935 - Throwing cards away I
- UVa-10935 - Throwing cards away I
- UVa 10935 - Throwing cards away I
- UVa 10935 Throwing cards away I
- UVA10935 Throwing cards away I【模拟+queue+循环队列】
- UVA10935 - Throwing cards away I