take any 4 input numbers. like 2345.. wanted out put is All 16 combinations of the number 2345..
for example-
taking input as 4565
output-
5654
4556
4655..

Answer Posted / anitha

package com.boa.example.java;

public class NumberTest {

public void swapnum(int a,int b,int c,int d){

for(int x=0;x<=3;x++){
int t1=0;
int t2=0;
int t3=0;

if(x == 0){
t1= b;
t2=c;
t3=d;
}

if(x == 1){
t1= c;
t2=b;
t3=d;
}

if(x == 2){
t1= c;
t2=d;
t3=b;
}
if(x == 3){
t1= b;
t2=d;
t3=c;
}
System.out.println(a+""+t1+""+t2+""+t3 );
}
}

public static void main(String args[]){
int i=1;
int j=2;
int k=3;
int l =4;

NumberTest n = new NumberTest();
n.swapnum(i,j,k,l);
n.swapnum(j,k,l,i);
n.swapnum(k,l,j,i);
n.swapnum(l,k,j,i);
}
}
o/p-1234
1324
1342
1243
2341
2431
2413
2314
3421
3241
3214
3412
4321
4231
4213
4312

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is cout buffered?

691


what is deadlock? : Java thread

532


What are features of java?

564


What is flag in java?

539


What is a method header?

554






Is nullpointerexception checked or unchecked?

559


What is serial version uid and its importance in java?

606


What is a file pointer?

521


What is difference between word and integer?

601


What is singleton service?

516


which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

9266


Is hashset sorted in java?

672


Why collection doesn’t extend cloneable and serializable interfaces?

651


Can list be final in java?

491


Is it possible to instantiate the abstract class?

542