Write a function that takes a string as input and reverse only the vowels of a string.

Example 1:
Given s = "hello", return "holle".

Example 2:
Given s = "leetcode", return "leotcede".

 char* reverseVowels(char* s) {
int i;
int j;
char temp;
i = ;
j = strlen(s) - ;
while(i < j){ if(s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u' && s[i] != 'A' && s[i] != 'E' && s[i] != 'I' && s[i] != 'O' && s[i] != 'U')
i++;
if(s[j] != 'a' && s[j] != 'e' && s[j] != 'i' && s[j] != 'o' && s[j] != 'u' && s[j] != 'A' && s[j] != 'E' && s[j] != 'I' && s[j] != 'O' && s[j] != 'U')
j--;
if((s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o'|| s[i] == 'u' || s[i] == 'A' || s[i] == 'E'|| s[i] == 'I'|| s[i] == 'O'|| s[i] == 'U') && (s[j] == 'a' || s[j] == 'e' || s[j] == 'i' || s[j] == 'o'|| s[j] == 'u' || s[j] == 'A' || s[j] == 'E'|| s[j] == 'I'|| s[j] == 'O'|| s[j] == 'U'))
{
temp = s[i];
s[i] = s[j];
s[j] = temp;
i++;
j--;
} }
return s;
}

Reverse Vowels of a String的更多相关文章

  1. 345. Reverse Vowels of a String(C++)

    345. Reverse Vowels of a String Write a function that takes a string as input and reverse only the v ...

  2. 【leetcode】345. Reverse Vowels of a String

    problem 345. Reverse Vowels of a String class Solution { public: string reverseVowels(string s) { , ...

  3. 345. Reverse Vowels of a String【easy】

    345. Reverse Vowels of a String[easy] Write a function that takes a string as input and reverse only ...

  4. LeetCode_345. Reverse Vowels of a String

    345. Reverse Vowels of a String Easy Write a function that takes a string as input and reverse only ...

  5. 345. Reverse Vowels of a String - LeetCode

    Question 345. Reverse Vowels of a String Solution 思路:交换元音,第一次遍历,先把出现元音的索引位置记录下来,第二遍遍历元音的索引并替换. Java实 ...

  6. [LeetCode] Reverse Vowels of a String 翻转字符串中的元音字母

    Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...

  7. LeetCode Reverse Vowels of a String

    原题链接在这里:https://leetcode.com/problems/reverse-vowels-of-a-string/ 题目: Write a function that takes a ...

  8. 345. Reverse Vowels of a String

    Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...

  9. Python [Leetcode 345]Reverse Vowels of a String

    题目描述: Write a function that takes a string as input and reverse only the vowels of a string. Example ...

随机推荐

  1. [ CodeVS冲杯之路 ] P1368

    不充钱,你怎么AC? 题目:http://codevs.cn/problem/1368/ 嗯……泡泡堂,很劲啊,其实就是个盗版的田忌赛马 http://www.cnblogs.com/hyfer/p/ ...

  2. Leveldb 实现原理

    原文地址:http://www.cnblogs.com/haippy/archive/2011/12/04/2276064.html LevelDb日知录之一:LevelDb 101 说起LevelD ...

  3. Effective Modern C++翻译(3)-条款2:明白auto类型推导

    条款2 明白auto类型推导 如果你已经读完了条款1中有关模板类型推导的内容,那么你几乎已经知道了所有关于auto类型推导的事情,因为除了一个古怪的例外,auto的类型推导规则和模板的类型推导规则是一 ...

  4. 【SSH 1】SSH框架的基本理解

    导读:在结束了BS之后,接触到的第一个项目算是网上商城了.这次用到了和之前都不一样的框架:SSH.这个项目就和之前学牛腩一样,有着里程碑的意义.当然了,这也就意味着,什么都是新鲜的,接触到的东西,有时 ...

  5. ssh注解basedao简单的实现

    @Repository public class BaseDao extends HibernateDaoSupport{ protected Class objectClass; protected ...

  6. python md5

    import hashlib import os 简单的测试一个字符串的MD5值 src = 'teststring' print (hashlib.md5(src).hexdigest().uppe ...

  7. js中字符串,数字之间转换的常用方法

    var number={ num:, num1:"2你好" }; //将数字转换为字符串 var str=number.num.toString();//十进制 );//二进制 ) ...

  8. 【MySQl】MyISAM和InnoDB索引对比

    部分内容转自:http://www.2cto.com/database/201211/172380.html 比较好的文章:http://www.cnblogs.com/hustcat/archive ...

  9. WP_3种磁贴效果设置

    private void ApplicationBarIconButton_Click_1(object sender, EventArgs e) { var tileData = new FlipT ...

  10. ntfs安全权限和共享权限的区别

    win xp 最大分区32G,最大文件大小4G. 共享权限是为网络用户设置的,NTFS权限是对文件夹设置的. 用户对文件夹有什么权限就是看NTFS权限的设置. 如果一个文件夹设置成共享,其具体的权限还 ...