Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Big probem for me to change to code.
The below is my code to print permuation of 123:

public class per {

public static void main(String[] args) {

permutation("123", "");

}

private static void permutation(String p1, String p2) {
if (p1.length() == 0)
System.out.println(p2);
else {
for (int i = 0; i < p1.length(); i++)
permutation(p1.substring(0,i) + p1.substring(i+1), p2 + p1.charAt(i));
}
}

}

The results is:
123
132
213
231
312
321

What I want to do is that when (p1.substring(0,i) + p1.substring(i+1)) is
"2", do next line.
For example, that condition comes true when doing the line of "132", the
remaining process to produce "132" skipped and to do next line "213".

Any idea would be appreciated.


Report this thread to moderator Post Follow-up to this message
Old Post
George
03-30-08 12:09 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:33 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.