标签:i++ txt poj2718 ext stdin cout perm iostream std
#include"iostream" #include"stdio.h" #include"algorithm" #include"string.h" using namespace std; int num[15]; int used[15]; int cnt; int GetNum(int *a,int len) { if(a[0]==0&&len>1) return -1; int sum=0; for(int i=0;i<len;i++) sum=sum*10+a[i]; return sum; } int Permutation() { int miniDiff=10000000; do { /* int m=GetNum(num,cnt/2); int n=GetNum(&num[cnt/2],cnt/2); if(m!=-1&&n!=-1) { if(abs(m-n)<miniDiff) miniDiff=abs(m-n); } */ for(int i=0;i<cnt;i++) cout<<num[i]<<‘ ‘; cout<<endl; }while(next_permutation(num,num+cnt)); return miniDiff; } int main() { freopen("in.txt","r",stdin); int t; while(scanf("%d",&t)==1) { memset(used,0,sizeof(used)); cnt=-1; while(scanf("%d",&num[++cnt])==1); cout<<Permutation()<<endl; } return 0; }
标签:i++ txt poj2718 ext stdin cout perm iostream std
原文地址:https://www.cnblogs.com/acm-jing/p/9589944.html