本文整理汇总了C++中permute函数的典型用法代码示例。如果您正苦于以下问题:C++ permute函数的具体用法?C++ permute怎么用?C++ permute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了permute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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
}
}
}
示例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");
}
示例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);
}
}
}
示例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));
}
}
}
示例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));
}
}
}
示例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
}
}
}
示例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
}
}
}
示例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();
}
}
}
示例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
示例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.
}
}
}
示例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++;
}
}
示例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);
}
}
示例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]);
}
}
示例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;
}