UVa 11925 - Generating Permutations
来源:互联网 发布:时时彩组选计划软件 编辑:程序博客网 时间:2024/05/21 11:04
这题用了冒泡排序的思想,不过紫书上的描述有误,建议参考原题。
#include <bits/stdc++.h>using namespace std;deque<int> a;vector<int> res;bool is_order(){for (int i = 1; i != a.size(); ++i)if (a[i] < a[i-1])return false;return true;}int main(){int n;while (a.clear(), res.clear(), cin >> n, n){for (int i = 0; i < n; ++i){int t; cin >> t; a.push_back(t);}while (!is_order()){if (a[0]>a[1] && a[0]!=n){swap(a[0], a[1]);res.push_back(1);}else{int t = a.back();a.pop_back();a.push_front(t);res.push_back(2);}}for(vector<int>::reverse_iterator it = res.rbegin(); it != res.rend(); ++it) cout << *it; cout << endl;}return 0;}
0 0
- UVa:11925 Generating Permutations
- UVa 11925 - Generating Permutations
- UVa 11925 Generating Permutations
- UVa - 11925 - Generating Permutations
- UVA 11925 Generating Permutations
- UVA 11925 - Generating Permutations
- UVA - 11925 Generating Permutations 推理
- UVA 11925(p254)----Generating Permutations
- UVa #11925 Generating Permutations (习题8-7)
- UVa 11925 - Generating Permutations(构造法)
- UVa 11925:Generating Permutations(构造)
- uva 11925——Generating Permutations
- UVA 11925 Generating Permutations 逆向思维
- Generating Permutations UVA
- 11925 - Generating Permutations
- 习题8-7 UVA - 11925 Generating Permutations 生成排列(构造)
- 生成排列 Generating Permutations
- UVa 10098 Generating Fast
- Ueditor截屏集成报错解决方法
- Linux那些事儿之我是Sysfs(6)文件系统
- Win10,为物联网提供强劲动力
- 缓存的实现,主要是图片缓存整理
- presentViewControl视图大小控制真奇葩
- UVa 11925 - Generating Permutations
- Android Studio发布项目到Jcenter
- 浅析alsa声卡驱动snd_pcm_start函数-将音频数据真实的发送到外部音频接口硬件
- bash 的快捷键
- C指针
- 关于 Java 的break,continue,return 的用法
- redis主从配置及通过keepalived实现redis自动切换
- xcode6下百度地图开发注意事项
- c语言中获取整数和浮点数的符号位