Ben Bacarisse wrote:
Newbie <ne****@gmail.comwrites:
>Ben Bacarisse wrote:
>>Newbie <ne****@gmail.comwrites:
#include <stdio.h>
#include <string.h>
....snip..
Ah, homework?
No . Writing a recursive solution is a lot easier(even an iterative
one). In fact i don't need the "rotation" method if duplicate elements
are not a concern.
i know its pretty silly but i just cannot figure it out at this point of
time.
for(outer = unchanged; outer < n; outer++)
{
/*Rotate the array to the right*/
do {
temp = Perm[outer];
for(inner = outer; inner unchanged; inner--){
Perm[inner] = Perm[inner - 1];
}
Perm[unchanged] = temp;
/*Done Rotation*/
}while( temp == Perm[unchanged]);
This is an infinite loop.I guess the while statement should be while (
temp == Perm [outer]).Tried increasing outer(keeping bounds in mind)
inside the do {} part as well but nothing will work when I really need
it to.
Anyways thanks for the reply.