POJ 2245 Lotto dfs
2015-07-07 22:45
288 查看
给出最多13个数,从中选出6个数(升序)
给出所有方案(升序输出)
DFS水题
View Code
给出所有方案(升序输出)
DFS水题
#include <cstring> #include <cstdio> #include <algorithm> using namespace std; const int N = 10; const int M = 16; int ans ; int a[M]; int n; void dfs(int id, int pre){ if(id == 6) { for(int i = 0; i < 6; i++) printf("%d%c", ans[i], i == 5 ? '\n' : ' '); return ; } if(pre == n) return; ans[id] = a[pre + 1]; dfs(id + 1, pre + 1); dfs(id, pre + 1); } int main(){ int i; bool newline = false; while(scanf("%d", &n) &&n){ if(newline) printf("\n"); for(i = 1; i <= n; i++){ scanf("%d", &a[i]); } newline = true; dfs(0, 0); } }
View Code
相关文章推荐
- SWIFT中隐藏TableView多余的分隔线
- EPOLL使用心得
- Ubuntu下qBittorrent下载工具的安装
- 单例模式具体事例,用到window下多线程,线程锁,模板等功能
- 如何成为uber司机,uber司机详细注册流程
- Red Hat Enterprise Linux 7 SystemTap Tapset Reference
- 第五次慕课总结
- textView设置粗体以及textView文字中划线
- 文章标题
- doT.js详细使用介绍
- Atitit.jquery 版本新特性attilax总结
- Atitit.jquery 版本新特性attilax总结
- struts2 package元素配置
- sicily 题目纠错
- Foundation框架-04 常用结构体(CGPoint、CGSize、CGRect)
- LNMP(CentOS 6.5 64位)下Phalcon框架的手动安装
- 从HttpRequestMessage的Content中同步读取Stream
- if语句之求一元二次方程
- 第四次慕课总结
- hdu 1241 Oil Deposits