hdu 1716 排列2(next_permutation函数应用)
来源:互联网 发布:知天下资源吧 ztx8.org 编辑:程序博客网 时间:2024/05/21 11:26
题目链接:点击打开链接
next_permutation要用do_while形式,不然会落下初始的排列,返回值是是否有下一个比当前数字典序高的排列
每组数据间有空行,行尾无空格要注意。
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[5];bool vis[5];int main(){ bool flag=0; while(~scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4])){ if(!a[1]&&!a[2]&&!a[3]&&!a[4]) break; sort(a+1,a+5); int t=-1; do{ if(!a[1])continue; if(a[1]!=t){ t=a[1]; if(!flag) flag=1; else printf("\n"); } else printf(" "); for(int i=1;i<=4;i++){ printf("%d",a[i]); } }while(next_permutation(a+1,a+5)); printf("\n"); } return 0;}
0 0
- hdu 1716 排列2(next_permutation函数应用)
- HDU 1716 排列2 (stl,next_permutation)
- HDOJ 1716 排列2(next_permutation函数)
- HDOJ 1716 排列2(next_permutation函数)
- HDU 1716 排列2(全排列函数的应用)
- HDOJ 1716 排列2 next_permutation函数
- 排列2 + stl函数+ next_permutation()
- 全排列函数 next_permutation()
- next_permutation函数(全排列)
- next_permutation函数(全排列)
- hdu 1027 全排列函数next_permutation运用
- hdoj 1716 排列2 (全排列 next_permutation())
- HDU1716 next_permutation 的简单应用 排列2
- POJ1833 排列(next_permutation()的应用)
- 排列 next_permutation的应用
- 求全排列函数 (next_permutation())
- hdu1027 全排列(STL函数next_permutation)
- poj1833 排列 next_permutation函数
- makefile常用语法讲解(1)
- 成长路上常见的坑
- IOS编程教程:在故事板联线(Segue)中的不同视图控制器里传值
- Excel 2010使用记录
- UF超滤膜:UF超滤膜系统相关性能原理
- hdu 1716 排列2(next_permutation函数应用)
- CF 461B - Appleman and Tree(树形DP)
- IOS编程教程:storyboard创建标签栏和网页视图
- 内核通知链
- Spring配置Quartz任务调度
- quartz定时任务时间设置描
- IOS编程教程: storyboard如何往表视图(Table View)添加搜索栏(Search Bar)
- 简单模拟Spring AOP功能 (1) AOP编程思想的理解
- java 垃圾回收总结(1)