Permutation available for duplicate element
来源:互联网 发布:tango软件好不好 编辑:程序博客网 时间:2024/05/22 08:10
const int N=10;
int pcnt[N], u_cnt;
char s[N],ps[N];
void Permu(char *pch, int *pint){
char *pch2=pch;
int *pint2=pint;
while(pch2<ps+u_cnt){
swap(pch, pch2), swap(pint, pint2);
(*pint)--;
if(*pint==0) Permu(pch+1, pint+1);
else Permu(pch, pint);
(*pint)++;
swap(pch, pch2), swap(pint, pint2);
return;
}
for(pch2=ps,pint2=pcnt;pch2<=ps+u_cnt;pch2++,pint2++){
int i=(*pint2);
while(i>0) cout<<(*pch2);
}
cout<<endl;
return;
}
void Compute(){
int i,k=0;
ps[k]=s[0];
pcnt[k]=1;
for(i=1;i<N;i++){
if(s[i]==ps[k])pcnt[k]++;
else ps[++k]=s[i], pcnt[k]=1;
}
u_cnt=k;
Permu(ps, pcnt);
}
// 12'
int pcnt[N], u_cnt;
char s[N],ps[N];
void Permu(char *pch, int *pint){
char *pch2=pch;
int *pint2=pint;
while(pch2<ps+u_cnt){
swap(pch, pch2), swap(pint, pint2);
(*pint)--;
if(*pint==0) Permu(pch+1, pint+1);
else Permu(pch, pint);
(*pint)++;
swap(pch, pch2), swap(pint, pint2);
return;
}
for(pch2=ps,pint2=pcnt;pch2<=ps+u_cnt;pch2++,pint2++){
int i=(*pint2);
while(i>0) cout<<(*pch2);
}
cout<<endl;
return;
}
void Compute(){
int i,k=0;
ps[k]=s[0];
pcnt[k]=1;
for(i=1;i<N;i++){
if(s[i]==ps[k])pcnt[k]++;
else ps[++k]=s[i], pcnt[k]=1;
}
u_cnt=k;
Permu(ps, pcnt);
}
// 12'
- Permutation available for duplicate element
- Duplicate <http> element detected
- js-remove duplicate array element
- Ways Available To Identify HTML Element
- Ways Available To Identify HTML Element
- Duplicate entry for key
- Duplicate entry '**' for key '***'
- Configuration problem: Duplicate <http> element detected
- all available command for windows
- No TypeTag available for person
- duplicate symbols for architecture armv6
- Duplicate entry '##' for key 'PRIMARY'
- duplicate symbols for architecture i386
- duplicate symbol for architecture armv7
- duplicate symbols for architecture arm64
- duplicate symbols for architecture armv7
- duplicate symbols for architecture x86_64
- duplicate symbols for architecture x86_64
- MessageBox函数
- 祝大家元旦快乐,新年快乐!
- 世界上并没有成为高手的捷径,但一些基本原则是可以遵循的
- 将JAVA程序做成WINDOWS服务的方法
- 外企攻略(转贴)
- Permutation available for duplicate element
- 不要在我寂寞的时候说爱我
- 第一次在这里写东西 留脚印
- 数学之美系列 二十三 输入一个汉字需要敲多少个键 — 谈谈香农第一定律
- 进程间通信的方式
- 一个可爱女孩的暴多糗事
- [读书笔记]INTRODUCING SCA摘记
- 新锐2007天涯上刀光剑影的激进言论
- 好书推荐:J2EE design pattern