SWAP EACH CONSECUTIVE PAIRS UNTIL THERE IS NO PAIR and THEN REVERSE THE VOWELS ---> INPUT:-NAGIEM OUTPUT:-ENIGMA
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;a
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner input = new Scanner(System.in);
String s = input.nextLine();
char[] sCharArray = s.toCharArray();
char[] newWordArray = new char[sCharArray.length];
char temp;
int firstletter=0;
int secondletter=1;
int length = sCharArray.length;
for(int i=0,n=length/2;i<n;i++)
{
temp= sCharArray[firstletter];
sCharArray[firstletter]=sCharArray[secondletter];
sCharArray[secondletter]=temp;
firstletter=firstletter+2;
secondletter=secondletter+2;
}
String news = new String(sCharArray);
System.out.println(news);
int j=0;
for(int i=0,n=sCharArray.length;i<n;i++)
{
if(Character.toLowerCase(sCharArray[i])=='a'||Character.toLowerCase(sCharArray[i])=='e'||Character.toLowerCase(sCharArray[i])=='i'||Character.toLowerCase(sCharArray[i])=='o'||Character.toLowerCase(sCharArray[i])=='u')
{
newWordArray[j]=sCharArray[i];
j++;
}
}
int end = j-1;
for(int i=0,n=sCharArray.length;i<n;i++)
{
if(Character.toLowerCase(sCharArray[i])=='a'|| Character.toLowerCase(sCharArray[i])=='e'||Character.toLowerCase(sCharArray[i])=='i'||Character.toLowerCase(sCharArray[i])=='o'||Character.toLowerCase(sCharArray[i])=='u')
{
sCharArray[i]=newWordArray[end];
end--;
}
}
String finalAnswer = new String(sCharArray);
System.out.println(finalAnswer);
}
}
import java.util.*;
import java.lang.*;
import java.io.*;a
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner input = new Scanner(System.in);
String s = input.nextLine();
char[] sCharArray = s.toCharArray();
char[] newWordArray = new char[sCharArray.length];
char temp;
int firstletter=0;
int secondletter=1;
int length = sCharArray.length;
for(int i=0,n=length/2;i<n;i++)
{
temp= sCharArray[firstletter];
sCharArray[firstletter]=sCharArray[secondletter];
sCharArray[secondletter]=temp;
firstletter=firstletter+2;
secondletter=secondletter+2;
}
String news = new String(sCharArray);
System.out.println(news);
int j=0;
for(int i=0,n=sCharArray.length;i<n;i++)
{
if(Character.toLowerCase(sCharArray[i])=='a'||Character.toLowerCase(sCharArray[i])=='e'||Character.toLowerCase(sCharArray[i])=='i'||Character.toLowerCase(sCharArray[i])=='o'||Character.toLowerCase(sCharArray[i])=='u')
{
newWordArray[j]=sCharArray[i];
j++;
}
}
int end = j-1;
for(int i=0,n=sCharArray.length;i<n;i++)
{
if(Character.toLowerCase(sCharArray[i])=='a'|| Character.toLowerCase(sCharArray[i])=='e'||Character.toLowerCase(sCharArray[i])=='i'||Character.toLowerCase(sCharArray[i])=='o'||Character.toLowerCase(sCharArray[i])=='u')
{
sCharArray[i]=newWordArray[end];
end--;
}
}
String finalAnswer = new String(sCharArray);
System.out.println(finalAnswer);
}
}
Comments
Post a Comment