Saturday, August 15, 2009

Permutaions



/**
Title : Program to print all permutations of a given ascendingly sorted integer array (Excluding Duplicates).
Author : Balakrishnan.B
Date/Time : Saturday 15 August 2009 08:40:23 PM IST
Language : C
Compiler : gcc (Ubuntu 4.3.2-1ubuntu12) 4.3.2
**/
#include
void reverse(int* f,int* l)
{
while(f< *p2) { int* p3 = l; while(*p1 > *p3)
p3--;
swap(p1,p3);
reverse(p2,l);
return 1;
}
if(p1==f)
{
reverse(f,l);
return 0;
}
}
}
void print_perms(int* a,int size)
{
do
{
int i;
for (i = 0; i <>

No comments:

Post a Comment