Sunday, 12 January 2014

Java problem to delete all duplicate digits from an input number?

Java problem to delete all duplicate digits from an input number?

Question:Write a program in java to delete all duplicate digits from an input number?

 Eg: if input is 112354 then output will be 12354 

Answer

import java.util.*;
public class duplicate {

public static void main(String args[]) 
{ long n;
int i=0,l=0,k=0;

Scanner sc=new Scanner(System.in);
System.out.println("Enter the number:");
n=sc.nextLong();
String s=Long.toString(n);
char c[]=new char[s.length()];
ArrayList cc=new ArrayList();
String temp = Long.toString(n);
int[] arr = new int[temp.length()];
for (int m = 0; m< temp.length(); m++)
{
arr[m] = temp.charAt(m) - '0';
}
for(i=0;i<s.length();i++)
{
for(int j=0;j<s.length();j++)
{

if(arr[i]==arr[j]&&i!=j)
{
l=1;
}

}
if(l==0)
{
cc.add(arr[i]);
k++;
}
l=0;
}
Iterator itr=cc.iterator();
while(itr.hasNext())
{
Object ans=itr.next();
System.out.print(ans);

}
}
}


Posted By:Tanuj Kumar 
On:Shareyourconscience

Read More
Posted on 11:43:00 pm
Categories:

Thursday, 2 January 2014

Free facebook


Free facebook

Free facebook on airtel limited period offer.

1 .Offer available till 31st January 2014 only

2. Facebook is available in 9 Indian Languages - Hindi, Gujarati, Marathi, Bengali, Punjabi, Tamil, Telugu, Kanadda, Malyalam.

More...

Now free Facebook offer is finished.
But you can enjoy  Airtel Freezone @3G Speed

1.Gmail
2.Google Plus
access freezone by click here....
FreeZone



Posted By:Tanuj Kumar 
On:Shareyourconscience

Read More
Posted on 3:51:00 am
Categories: