Reverse Vowels of a String
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的更多相关文章
- 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 ...
- 【leetcode】345. Reverse Vowels of a String
problem 345. Reverse Vowels of a String class Solution { public: string reverseVowels(string s) { , ...
- 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 ...
- 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 ...
- 345. Reverse Vowels of a String - LeetCode
Question 345. Reverse Vowels of a String Solution 思路:交换元音,第一次遍历,先把出现元音的索引位置记录下来,第二遍遍历元音的索引并替换. Java实 ...
- [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 ...
- LeetCode Reverse Vowels of a String
原题链接在这里:https://leetcode.com/problems/reverse-vowels-of-a-string/ 题目: Write a function that takes a ...
- 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 ...
- 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 ...
随机推荐
- Photoshop Cs5 64位系统破解版下载(内含破解方法)
Photoshop Cs5 64位系统是电影.视频和多媒体领域的专业人士, 使用 3D 和动画的图形和 Web 设计人员, 以及工程和科学领域的专业人士的理想选择,下面提供Photoshop Cs5 ...
- git 仓库操作
一.git 仓库从远程clone 首先要建立一个本地空目录文件比如 RuntimeJsonModel,然后: 1. git init 2. git clone https://github.com/G ...
- Flex Alert的匿名回调函数如何得到正确的this
Flex中经常使用Alert来弹出提示或确认窗口,为了方便省事,会直接用匿名函数作为回调,但有时如果要调用外部的this,你会发现匿名函数中的this无法指向外部父类,可以使用e.target获取pa ...
- AD采样问题总结
说明:来源http://bbs.csdn.net/topics/390899032论坛讨论 一个100HZ的正弦波,我用300HZ的采样率去采样,那么根据香农定律是不是一秒钟就采集到300个点,因为这 ...
- Retina CS强大漏洞检测工具
RetinaCS强大漏洞检测工具 Eeye数字安全公司成立于上世纪九十年代末期,它是世界领先的安全公司,它采用最新研究成果和创新技术来保证您的网络兄系统安全,并向您提供最强大的如下服务:全面的.漏洞评 ...
- ax 的错误处理范例
#OCCRetryCount ; try { ttsbegin; //example as insert or update or delete record ttscommit; } catch(E ...
- servlet 启动加载配置文件及初始化
在servlet开发中,会涉及到一些xml数据的读取和一些初始化方法的调用.可以在tomcat启动的时候,加载一个servlet去初始化一些数据. 摘自 http://stone02111.iteye ...
- 解决 FastReport 使用存储过程 找不到临时表问题
在存储过程最开始加入:以下命令就可以了 SET FMTONLY OFF 有时候在执行SQL查询语句时,仅仅需要知道检索的元数据,而不是具体的数据行,可以设置SET FMTONLY ON. SET FM ...
- final 的用法总结
1.修饰成员变量 修饰普通变量 表明这个变量是一个常量,不可以修改这个变量的值,一般这样的变量的变量名都要大写 修饰引用变量 表明这个引用不能够指向别的对象了,只能够指向指定的这个对象 2.修饰方法 ...
- DirectDraw打造极速图形引擎(Alpha混合)
显然DirectDraw是Windows下写2D图形程序的最好选择,虽然Direct3D也可以写,但是没DirectDraw简单方便,特别对于初学者,一来就接触那么多函数和参数总不是件愉快的事,所以我 ...