You are on page 1of 1

public static String TwoWOds(String Str,int input2)

{
String st[]=Str.split("\\s");
int w1=input2/10;
int w2=input2%10;
String ww0=st[w1-1];
String ww1=st[w2-1];
int len=ww0.length()/2-1;
if(ww0.length()%2!=0)
len++;
String temp="";
for(int i=len;i>-1;i--)
{
temp=temp+ww0.charAt(i);
}
temp+=ww0.substring(ww0.length()/2);
ww0=temp;
len=ww1.length()/2-1;
if(ww1.length()%2!=0)
len++;
temp="";
for(int i=len;i>-1;i--)
{
temp=temp+ww1.charAt(i);
}
temp+=ww1.substring(ww1.length()/2);
ww1=temp;
return ww0+" "+ww1;
}

You might also like