Skip to main content

Given a string, reverse only vowels in it; leaving rest of the string as it is

/* Given a string, reverse only vowels in it; leaving rest of the string as it is.

Input : abcdef
Output : ebcdaf */
import java.io.*;
import java.util.*;

public class VowelReverse {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
String vowels = "";
String ans = "";
int arr[] = new int[str.length()];
for(int i=0;i<str.length();i++) {
if(str.charAt(i)=='a' || str.charAt(i)=='e' || str.charAt(i)=='i' || str.charAt(i)=='o' || str.charAt(i)=='u') {
vowels+=str.charAt(i);
arr[i]=1;
}
}
String revVowels = new StringBuffer(vowels).reverse().toString();
int j=0;

for(int i=0;i<str.length();i++) {
if(arr[i]!=1) {
ans+=str.charAt(i);
}
else {
ans+=revVowels.charAt(j);
j++;
}
}
System.out.println(ans);

}
}

Comments

Popular posts from this blog

ரிதம்பாக்ஸில் ரேடியோ மிர்ச்சி

உபுண்டு 12.04ல் bansheeயை தூக்கிவிட்டு மறுபடியும் rhythmbox default இசைப்பானாக இடம்பெற்றுள்ளது. ரிதம்பாக்ஸ்ல் bansheeயை விட பல அம்சங்கள் குறைவுதான். ஏன் banshee ஐ எடுத்தார்கள் என்று  சரியாக புரியவில்லை. என்னதான் high-bitrateல் பாடல்கள் இருந்தாலும் fm கேட்பது ஒரு மகிழ்ச்சிதான். சில வருடங்களுக்கு முன்பு எங்கள் தெருக்களில் சூரியன் fm, ரேடியோ மிர்ச்சி போன்றவை தான் என்னை எழுப்பும்.

need your response

It has been a long time... my rest hours are reduced i only sleep for 5 to 6 hours a day.. so i can't post frequently.. sorry friends.. my university is a good place to refine myself. yes..! thoughts about my programming computers are refined there.. i always wanted share my experience.. but i feared of thinking that it will helpful for you or not.. most of us don't like to hear stories of others. so i stopped blogging and of course having less time.. i have earned some good friends there... who are interested in open-source technology.. very few of us only know the linux platform.. this semester mini project also in open softwares like mysql, postgrey sql i will start blogging my experience if you are interested.. regards, Mani G

உபுண்டு டெர்மினலில் இருந்து இலவசமாக sms அனுப்பலாம்

இன்று டெர்மினலில் இருந்து எப்படி இலவசமாக sms அனுப்புவது என்று பார்க்கலாம். way2sms சென்று sms அனுப்புவதற்கு அந்த தளத்தின் விளம்பரங்களை தாண்டிதான் அனுப்ப வேண்டியிருக்கிறது. விளம்பரங்களை பார்க்கமால் சுலபமாக இந்த script ஐ பயன்படுத்தி இலவசமாக sms அனுப்பலாம். இதற்கு முதலில் way2sms ன் பயனராக இருக்க வேண்டும். இல்லை என்றால way2sms.com சென்று ஒரு அக்கவுண்டினை தொடங்கிகொள்ளவும். username, password  வேண்டும்.