> hi all,
>
[quoted text clipped - 13 lines]
>
> thank you
Just a hint: nested for loops.
oh, and are you aware that what you want as output is not a
permutation?
-- Henk van Voorthuijsen
> hi all,
>
[quoted text clipped - 11 lines]
> i understand the algorithem, but still cant write it. could someone
> give me the source for this or help me to write it.
What's the algorithm?
- Oliver
Ken - 24 Feb 2007 18:16 GMT
> > i understand the algorithem, but still cant write it. could someone
> > give me the source for this or help me to write it.
>
> What's the algorithm?
>
> - Oliver
Oh thats quite simple...
1) Find a news group
2) Ask for group to do your homework
3) Read results
4) If results are not adequate branch to 1
> hi all,
>
[quoted text clipped - 13 lines]
>
> thank you
import ncst.pgdst.*;
public class permutation{
public static void main(String[] agrs)throws Exception
{
SimpleInput si=new SimpleInput();
Perm pm=new Perm();
pm.permute(0);
}
}
class Perm{
int n,r=3,count,size=3,RHS;
char charList[]=new char[26];
char chrs[]={'a','b','c'};
char arr[]={'a','b','c'};
void swap(char []a, int i, int j)
{
char temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
void permute(int start)
{
int i,j;
if(start==r)
{
{
for(i=0;i<r;i++)
System.out.print(charList[i]);
System.out.println();
}
}
else
{
i=start;
int k=0;
for(j=0;j<3;j++)
{
charList[i]=chrs[k++];
permute(start+1);
}
}
}
void permute2(int i)
{
int j=0,k=0;
char temp;
if(i == size)
{
return;
}
for(j = i; j < size; j++)
{
swap(arr,i,j);
permute2(i+1);
if(i == size - 1)
{
System.out.print("Permute["+count+"]=");
// for(k = 0;k< size;k++)
System.out.print(arr);
System.out.println();
swap(arr,j,i);
}
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
Hendrik Maryns - 21 Mar 2007 17:55 GMT
sohaninfo@gmail.com schreef:
>> hi all,
>>
[quoted text clipped - 17 lines]
>
> public class permutation{
<snip a solution> Tsk, tsk.
First of all: http://mindprod.com/jgloss/homework.html
But then, you could have done some searching:
http://mindprod.com/jgloss/permutation.html
H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Lew - 21 Mar 2007 20:17 GMT
> <snip a solution> Tsk, tsk.
>
> First of all: http://mindprod.com/jgloss/homework.html
>
> But then, you could have done some searching:
> http://mindprod.com/jgloss/permutation.html
It's been about four weeks. The homework had to have been due before now. It
should be safe to post a solution.
Maybe next semester's crowd will search Usenet for the answer and plagiarize
it then.
-- Lew