首页 > 其他 > 详细

反转字符串

时间:2016-10-09 07:03:27      阅读:181      评论:0      收藏:0      [点我收藏+]

Write a function that takes a string as input and returns the string reversed.

Example:
Given s = "hello", return "olleh".

char* reverseString(char* s) {
    int len = strlen(s);
    for (int i=0; i<len/2; i++) {
        char t = s[i];
        s[i] = s[len-i-1];
        s[len-i-1] = t;
    }
    return s;
}

 

反转字符串

原文:http://www.cnblogs.com/wxisme/p/5940663.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!