Given a string (array of character), split the string to half and reverse each half
Input:
Input String: "Mike"
Output: "iMek"
Input String: "break"
Output: "rbeka"
public String func(String str)
{
// write your code here
try{
int len=str.length(),length;
String result="";
length=(len/2)-1;
for(int i=length;i>=0;i--)
{
result=result+str.charAt(i);
}
if(len%2!=0)
{
result=result+str.charAt(len/2);
for(int i=len-1;i>length+1;i--)
{
result=result+str.charAt(i);
}}
else{
for(int i=len-1;i>length;i--)
{
result=result+str.charAt(i);
}
}
return result;
}
catch (Exception e)
{
String s="NULL";
return s;
}
}
Visit : https://c-programs-world.blogspot.in for more question
public String func(String str)
{
// write your code here
try{
int len=str.length(),length;
String result="";
length=(len/2)-1;
for(int i=length;i>=0;i--)
{
result=result+str.charAt(i);
}
if(len%2!=0)
{
result=result+str.charAt(len/2);
for(int i=len-1;i>length+1;i--)
{
result=result+str.charAt(i);
}}
else{
for(int i=len-1;i>length;i--)
{
result=result+str.charAt(i);
}
}
return result;
}
catch (Exception e)
{
String s="NULL";
return s;
}
}
Visit : https://c-programs-world.blogspot.in for more question
Betway Casino Resort - MapyRO
ReplyDeleteLocated 영주 출장안마 just five minutes from New Orleans' Boardwalk, the Betway 여주 출장샵 Casino Resort is a Native 삼척 출장마사지 American gaming destination featuring an 통영 출장마사지 all-new 구미 출장마사지 gaming experience.