Chinaunix首页 | 论坛 | 博客
  • 博客访问: 457708
  • 博文数量: 118
  • 博客积分: 4015
  • 博客等级: 上校
  • 技术积分: 1233
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-24 22:11
文章分类

全部博文(118)

文章存档

2013年(5)

2011年(61)

2010年(52)

分类: C/C++

2011-12-08 18:07:54

I Reconstruct my code , and implement with only one extra array
  1 #include
  2 using namespace std;
  3 int ShowResult(char *p,int l);
  4 int Permutation(char *p,char *EA, int l, int h);
  5 int Swap(char *p, int a, int b);
  6 int main(){
  7   int A[] = {1,2,3,4};
  8   char C[] = {'A','V','C','D'};
  9   char EC[4] ;
 10   Permutation(C,EC,0,4);
 11   return 0;
 12 }
 13 int Permutation(char *p,char *EA, int l, int h){
 14   if(l == h - 1){
 15     EA[4 - h + l]= p[l];
 16     ShowResult(EA,4);
 17     return 0;
 18   }
 19   for(int i = l; i < h; i ++){
 20     EA[4 - h + l]= p[i];
 21     Swap(p,i,h -1);
 22     Permutation(p,EA,l,h - 1);
 23     Swap(p,h - 1,i );
 24   }
 25   return 0;
 26 }
 27 int Swap(char *p, int a, int b){
 28   char t = p[a];
 29   p[a] = p[b];
 30   p[b] = t;
 31   return 0;
 32 }
 33 int ShowResult(char *p,int l){
 34   for(int i = 0; i < l - 1; i++)
 35     cout<
 36   cout<
 37   return 0;
 38 }

阅读(2073) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

pybmsk2012-11-03 16:48:19

PTC Creo 2.0 M010 Full Multilanguage WinALL-ISO 2DVD

PTC Creo/Illustrate (ex PTC IsoDraw) 2.0 WinALL-ISO 1DVD

PTC Creo Schematics (ex Routed Systems Designer) 2.0 M010-ISO 1CD

PTC Pro/E WildFire+Pro/Mechancia v6.0 Alpha Win32-ISO 3CD

PTC Creo Elements/Pro 5.0 M070 Working for Win32-ISO 1DVD(最新多语言正式版包括简、繁体中文)

PTC Creo Elements/Pro 5.0 M070 Working for Win64-ISO 1DVD

PTC Creo Elements View (ex Product View) v