UVA_11129_An antiarithmetic permutation
2016-04-12 14:58
316 查看
#include<iostream> #include<cstdio> #include<sstream> #include<string> #include<vector> #include<list> #include<set> #include<map> #include<stack> #include<queue> #include<algorithm> #include<cmath> #pragma warning(disable:4996) using std::cin; using std::cout; using std::endl; using std::stringstream; using std::string; using std::vector; using std::list; using std::pair; using std::set; using std::multiset; using std::map; using std::multimap; using std::stack; using std::queue; void recur(vector<int>value) { if (value.size() == 2) { printf(" %d %d", value[0],value[1]); return; } if (value.size() == 1) { printf(" %d", value[0]); return; } vector<int>value1, value2; for (size_t i = 0; i < value.size(); i+=2) { value1.push_back(value[i]); } for (size_t i = 1; i < value.size(); i += 2) { value2.push_back(value[i]); } recur(value1); recur(value2); } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt","w",stdout); int n; while (cin >> n) { if (!n) { break; } cout << n << ':'; vector<int>value; for (int i = 0; i < n; i++) { value.push_back(i); } recur(value); cout << endl; } return 0; }
相关文章推荐
- viewpager中彻底性动态添加、删除Fragment
- 使用Markdown编辑器写博客
- TCP/IP(一)基础
- mysql引擎
- 可以拖动的多张图片
- 使用两个栈实现队列
- Android中获取控件的位置宽高等信息都为0
- stm32内存空间分配学习
- RabbitMQ入门(三) —— fanout交换器
- STM32片上FLASH内存映射、页面大小、寄存器映射
- Android Service学习之本地服务
- WEB架构师成长之路
- C++实验3-分段函数求值
- 爬虫工具fiddler
- 版本更新提示用户更新
- 序列化类型为XX的对象时检测到循环引用
- System.Linq.Dynamic
- 详解Linux运维工程师必备技能
- java网络爬虫
- window如何杀死占用端口的进程