A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing


  • 4 years ago

A program in Bluej platform for generating permutations of a number?

  • This Question is Open
  1. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    import java.util.*; public class Permutation { static Scanner sc=new Scanner(System.in); public char[] arr; public int count; public Permutation(String word) { arr=word.toUpperCase().toCharArray(); count=0; } public void permute(int start) { if(start==arr.length-1) // TRIVIAL CASE { System.out.print(arr);System.out.print(" "); if((getCount()+1)%5==0)System.out.println(); count++; return; } for(int i=start;i<arr.length;i++) { // SWAPPING i-th AND start-th ELEMENT char temp=arr[i]; arr[i]=arr[start]; arr[start]=temp; permute(start+1); // SWAPPING TO ORIGINAL POSITION temp=arr[i]; arr[i]=arr[start]; arr[start]=temp; } } public int getCount(){ return count; } public static void main(String args[]) { System.out.print("Enter The Word : "); String word=sc.next(); System.out.println(); Permutation obj=new Permutation(word); obj.permute(0); // BEGIN WITH 1ST CHAR System.out.println("\nTotal No Of Permutation : "+obj.getCount()); } }

  2. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...


  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.