cci-Q1.2 C风格字符串反转
2013-07-08 18:28
429 查看
原文:
Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)
译文:
写代码翻转一个C风格的字符串。(C风格的意思是"abcd"需要用5个字符来表示,包含末尾的 结束字符)
C style string是指结尾有‘\0’结束符
Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)
译文:
写代码翻转一个C风格的字符串。(C风格的意思是"abcd"需要用5个字符来表示,包含末尾的 结束字符)
C style string是指结尾有‘\0’结束符
void reverse(char *str) { if (NULL == str) exit(-1); char *end; char tmp; while (*end) { end++; } end--; while (str < end) { tmp = *end; *end-- = *str; *str++ = tmp; } }
相关文章推荐
- 【Cracking the coding interview】Q1.2(反转字符串)
- 算法:反转一个C风格的字符串
- 1.2 实现C语言风格的字符串反转的算法
- CCI 1.2 反转字符串
- 字符串反转问题
- 如何将字符串反转
- C#--第九周实验--任务2--定义一个静态成员方法,该方法实现字符串反转。
- 算法-字符串反转
- 将整形数据转换为反转数字字符串输出
- java反转字符串
- python反转字符串的几种方式
- 2.字符串的反转,比如abcde,输出edcba
- 字符串反转
- 关于String字符串反转
- java基础将字符串进行反转
- php中文字符字符串反转字符串
- C风格字符串大写转小写
- 反转字符串的四种方法
- 字符串反转系列问题
- 混合使用标准库类 string 和 C 风格字符串