• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ permute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中permute函数的典型用法代码示例。如果您正苦于以下问题:C++ permute函数的具体用法?C++ permute怎么用?C++ permute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了permute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: des

    void des(const std::string& inp, std::string& key, std::string& p_encrypted) {
        boost::uint32_t c = bpermute(key.data(), 28, PC1[0]);
        boost::uint32_t d = bpermute(key.data(), 28, PC1[1]);
        boost::uint32_t l = rrotate(bpermute(inp.data(), 32, IP[0]),31);
        boost::uint32_t r = rrotate(bpermute(inp.data(), 32, IP[1]),31);

        boost::uint32_t rot=1;
        for(boost::uint32_t i=0;i<16;++i){
            boost::uint32_t k[2]=
            {
                permute(rrotate28(c,rot),24,PC2[1]),
                permute(rrotate28(d,rot),24,PC2[0])
            };

            for(boost::uint32_t j=0; j<8; ++j){
                boost::uint32_t x=k[j>>2]>>(j&3)*6;
                boost::uint32_t b=(rrotate(r,j*4)^x)&0x3f;
                boost::uint32_t s=(S[j][b>>3]>>((b&7)*4))&0xf;
                l^=rrotate(permute(s<<j*4,32,P),31);
            }
            boost::uint32_t t=l;
            l=r;
            r=t;
            ++rot;
            if(i!=0 && i!=7 && i!=14)
                ++rot;
        }
        char v[8]={};
        packbe(v,0,rrotate(r,1));
        packbe(v,4,rrotate(l,1));
        l=bpermute(v,32,FP[0]);
        r=bpermute(v,32,FP[1]);
        char out[8]={};
        packbe(out,0,l);
        packbe(out,4,r);
        p_encrypted.assign(out, 8);
    }
开发者ID:CallMeJonas,项目名称:jsproxy_crypto,代码行数:37,代码来源:des.cpp


示例2: permute

/* Function to print permutations of string
This function takes three parameters:
1. String
2. Starting index of the string
3. Ending index of the string. */
void permute(char *a, int i, int n)
{
	int j;
	if (i == n && a[0]!=0)
		printf("%s\n", a);
	else
	{
		for (j = i; j <= n; j++)
		{
			swap((a + i), (a + j));
			permute(a, i + 1, n);
			swap((a + i), (a + j)); //backtrack
		}
	}
}
开发者ID:kkaushi,项目名称:TestCodes,代码行数:20,代码来源:AllPermOfString.c


示例3: main

void main() {
	size_t * perm = malloc(sizeof(size_t) * 1000);
	struct rtree_t t = {0};
	int i, j, k;
	float pos[1000][3];
	float sml[1000];
	intptr_t key[1000];
	int l = 0;
	for(i = 0; i < 10; i++) {
		for(j = 0; j < 10; j++) {
			for(k = 0; k < 10; k++) {
				pos[l][0] = i * 0.1 * (1<<20);
				pos[l][1] = j * 0.1 * (1<<20);
				pos[l][2] = k * 0.1 * (1<<20);
				sml[l] = 0;
				key[l] = peano_hilbert_key(pos[l][0], pos[l][1], pos[l][2], 20);
				l++;
			}
		}
	}

	gsl_heapsort_index(perm, key, 1000, sizeof(intptr_t), (void*)intptr_t_compare);

	float (*__pos)[3] = permute(perm, pos, 3 * sizeof(float), 3 * sizeof(float), 1000, 1000);
	float * __sml = permute(perm, sml, sizeof(float), sizeof(float), 1000, 1000);
	intptr_t * __key = permute(perm, key, sizeof(intptr_t), sizeof(intptr_t), 1000, 1000);
	rtree_build(&t, __pos, __sml, __key, 1000);
	float dist[10];
	intptr_t nei[10];
	int nused = 0;
	float hhint = 100000;
	float p[3] = {499999, 499999,499999};

	rtree_neighbours(&t, p, __pos, 1000, nei, dist, 10, &nused, NULL);
	printf("hello\n");
}
开发者ID:rainwoodman,项目名称:psphray,代码行数:36,代码来源:rtree.c


示例4: permute

void permute(char *a, int i, int n) {
	int j;
	if (i == n) {
		strcpy(perm_head -> w, a);
		perm_head -> next = malloc(sizeof(permutes));
		perm_head = perm_head -> next;
	}
	else {
		for (j = i; j <= n; j++) {
			swap(a+i, a+j);
			permute(a, i+1, n);
			swap(a+i, a+j);
		}
	}
}
开发者ID:dzsdzs,项目名称:szokirako,代码行数:15,代码来源:scrabble.c


示例5: permute

void permute(char *a, int i, int n) 
{
   int j; 
   if (i == n)
     printf("%s\n", a);
   else
   {
        for (j = i; j <= n; j++)
       {
          swap((a+i), (a+j));
          permute(a, i+1, n);
          swap((a+i), (a+j)); 
       }
   }
} 
开发者ID:rishantagarwal,项目名称:Competitive_Programming,代码行数:15,代码来源:lex_permutation.c


示例6: permute

void permute (char * str, int start, int end)
{
	if (start == end)
		printf ("%s\n", str);
	else
	{
		int j;
		for (j = start; j <= end; j++)
		{
			swap ((str + start), (str + j));
			permute (str, start + 1, end);
			swap ((str + start), (str + j));
		}
	}
}
开发者ID:asm123,项目名称:Practice,代码行数:15,代码来源:permute_string.c


示例7: permute

void permute(char *a, int i, int n) 
{
   int j; 
   if (i == n-1)
     printf("%s\n", a);
   else
   {
        for (j = i; j <n; j++)
       {
          swap(&a[i], &a[j]);
          permute(a, i+1, n);
          swap(&a[i], &a[j]);//backtrack
       }
   }
} 
开发者ID:anshu89,项目名称:C-Cpp-Code,代码行数:15,代码来源:Permutation.cpp


示例8: permute

//function to generate permuted array and make the corresponding trees simultaneously with help from above function
void permute(int *a, int i, int n)
{
    int j;
    if(i==n) {
        maketree(a,n);
    }
    else {
        for (j = i; j <= n; j++)
        {
            swap((a+i), (a+j));
            permute(a, i+1, n);
            swap((a+i), (a+j)); //backtrack
        }
    }
}
开发者ID:akarshprabhu,项目名称:vacations15,代码行数:16,代码来源:nkeybst.c


示例9: permute

 // with extra space
 void permute(vector<int> &container, vector<bool> &visited, vector<int> &num, vector<vector<int> > &result) {
     if(container.size() == num.size()) {
         result.push_back(container);
         return;
     }
     for(int i = 0; i < num.size(); ++i) {
         if(!visited[i]) {
             visited[i] = true;
             container.push_back(num[i]);
             permute(container, visited, num, result);
             visited[i] = false;
             container.pop_back();
         }
     }
 }
开发者ID:Kaidul,项目名称:LeetCode_problems_solution,代码行数:16,代码来源:Permutations.cpp


示例10: permute

void permute(int *v, const int start, const int n)
{
   // print(v, n);
	test(v, n);
  if (start < n) {
    int i, j;
    for (i = n-2; i >= start; i--) {
      for (j = i + 1; j < n; j++) {
    swap(v, i, j);
    permute(v, i+1, n);
      } // for j
      rotateLeft(v, i, n);
    } // for i
  }
} // permute
开发者ID:mikeblas,项目名称:EulerSolutions,代码行数:15,代码来源:Euler41.cpp


示例11: permute

/* Function to print permutations of string This function takes three parameters:
 1. String
 2. Starting index of the string
 3. Ending index of the string. */
void permute(char *str, int start, int end)
{
 int i;
 if (start == end)
    printf("%s\n", str);
 else
 {
    for (i = start; i <= end; i++)
    {
      swap( (str + start), ( str + i) );
      permute(str, start+1, end);
      swap( (str + start), ( str + i) );                         // swap back to previous condition.
    }
 }
}
开发者ID:KunjeshBaghel,项目名称:DS,代码行数:19,代码来源:print_all_permutation_g4g.cpp


示例12: permute

    void permute(vector<int>& nums,int n, map<int,int> numToCount, vector<vector<int>>& res,vector<int>& perm,int count){
        if(count==n){
            res.push_back(vector<int>(perm));
            return;
        }
        for(map<int,int>::iterator it=numToCount.begin();it!=numToCount.end();++it){
                if(it->second==0) continue;
               perm.push_back(it->first);
               it->second--;
               permute(nums,n,numToCount,res,perm,count+1);
               perm.pop_back();
               it->second++;
           }

    }
开发者ID:XBOOS,项目名称:leetcode-solutions,代码行数:15,代码来源:permutations_II.cpp


示例13: permute

void permute(int start, int end, char *str) {
	if(start>end) {
		return;
	}
	if(start==end) {
		printf("%s\n",str);
		return;
	}
	int i=start;
	for(;i<=end;i++) {
		swap(str+start, str+i);
		permute(start+1, end, str);
		swap(str+i, str+start);
	}
}
开发者ID:okeashwin,项目名称:General,代码行数:15,代码来源:permutations.c


示例14: permute

    void permute(vector<vector<int>>& ans, vector<int>& perm, int begin)
    {
        if (begin == perm.size()) {
            ans.push_back(perm);
            return;
        }

        for (int i=begin; i<perm.size(); i++) {
            if (i!=begin && perm[i] == perm[begin]) continue;
            swap(perm[i], perm[begin]);
            permute(ans, perm, begin+1);
            swap(perm[i], perm[begin]);
        }

    }
开发者ID:imAArtist,项目名称:simIr,代码行数:15,代码来源:code_240.cpp


示例15: genShapes

void genShapes(int k)
{
  int * array;
  array = malloc(sizeof(int)*k);
  int i=0;
  for(i = 0; i < k; i++)
   {
      array[i] = i;
      //    printf("array[%d] = %d\n", i, array[i]);
    }

  permute(array, k);
  //printf
  return;
}
开发者ID:CindyCKL,项目名称:ece264-fall2013,代码行数:15,代码来源:answer10.c


示例16: permute

//to generate all the permutation of the keys
void permute(int *a, int i, int n) 
{
	int j;
	if(i==n)
		printArray(a,n);
	else 
	{
	        for (j = i; j <= n; j++) 	
		{
	          swap((a+i), (a+j));
	          permute(a, i+1, n);
	          swap((a+i), (a+j)); 
	       }
	}
}
开发者ID:Anukarsh,项目名称:Summer-15,代码行数:16,代码来源:BSTfromKeys.c


示例17: permute

int permute(char *a, int i, int n)
{
  int j;
  if(i==n)
    return a;
  else
    {
      for(j=i;j<=n;j++)
	{
	  swap((a+i), (a+j));
	  permute(a, i+1, n);
	  swap((a+i), (a+j));
	}
    }
}
开发者ID:tgallant,项目名称:euler,代码行数:15,代码来源:euler49.c


示例18: permute

/* Function to print permutations of string
   This function takes three parameters:
   1. String
   2. Starting index of the string
   3. Ending index of the string. */
void permute(char *a, int l, int r)
{
  int i;
  if (l == r)
    printf("%s\n", a);
  else
    {
      for (i = l; i <= r; i++)
        {
          swap((a+l), (a+i));
          permute(a, l+1, r);
          swap((a+l), (a+i)); //backtrack
        }
    }
}
开发者ID:anandkodnani,项目名称:C-,代码行数:20,代码来源:back.cpp


示例19: QR_decomposition

void QR_decomposition(double **A, double *gamma, int rows, int columns, int *permutation) {
	int k;
	double t, *norms, *max;
	norms = malloc(columns * sizeof(double));
	max = malloc(columns * sizeof(double));
	for (k = 0; k < columns; k ++) {
		update_norms_vector(A, rows, columns, norms, k, max);
		permute(A, rows, columns, permutation, norms, k);
		t = generating_Q(rows, A, k, gamma, norms);
		update_matrix(A, gamma, rows, columns, k);
		A[k][k] = -t;
	}
	free(max);
	free(norms);
}
开发者ID:msart,项目名称:MAC300_ep3,代码行数:15,代码来源:ep3.c


示例20: permute

/* Function to print permutations of string
   This function takes three parameters:
   1. String
   2. Starting index of the string
   3. Ending index of the string. */
void permute(char *a, int i, int n) 
{
   int j; 
   if (i == n)
     printf("%s\n", a);
   else
   {
        for (j = i; j <= n; j++)
       {
          swap((a+i), (a+j));
          permute(a, i+1, n);
          swap((a+i), (a+j)); //backtrack
       }
   }
} 
开发者ID:j-bharath,项目名称:Data-Structures-and-Algo-implementation-in-C,代码行数:20,代码来源:string_permutation.c



注:本文中的permute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ perp函数代码示例发布时间:2022-05-30
下一篇:
C++ perm函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap