public class NoRepetitionOfLettersInWord
{
void input(String a)
{
String ch="";
int i,j,l=a.length(),x=0;
char p,q;
String s=a.toLowerCase();
for(i=0;i<l;i++)
{
p=s.charAt(i);
for(j=i;j>=0;j--)
{
q=s.charAt(j);
if(p==q)
x++;
}
if(x==1)
ch=ch+p;
x=0;
}
System.out.println("Original Word="+s+"\nChanged Word="+ch);
}
}
{
void input(String a)
{
String ch="";
int i,j,l=a.length(),x=0;
char p,q;
String s=a.toLowerCase();
for(i=0;i<l;i++)
{
p=s.charAt(i);
for(j=i;j>=0;j--)
{
q=s.charAt(j);
if(p==q)
x++;
}
if(x==1)
ch=ch+p;
x=0;
}
System.out.println("Original Word="+s+"\nChanged Word="+ch);
}
}
No comments:
Post a Comment