题解 | #字符串反转#

字符串反转

https://www.nowcoder.com/practice/e45e078701ab4e4cb49393ae30f1bb04

#include<iostream>
#include<string>
using namespace std;

void StrReverse(string &str)
{
    int start=0;
    int end=str.size()-1;
    while(start<end)
    {
        int tmp=str[start];
        str[start]=str[end];
        str[end]=tmp;
        start++;
        end--;
    }
}


int main()
{
    string str;
    while(getline(cin,str))
    {
        StrReverse(str);
        cout<<str<<endl;
    }
    return 0;
}

全部评论

相关推荐

07-10 13:59
门头沟学院 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
07-07 12:47
门头沟学院 Java
码农索隆:竟然还真有卡体检报告的
点赞 评论 收藏
分享
昨天 12:09
门头沟学院 Java
讲的口干舌燥,头都晕了怎么要讲这么长啊
码农索隆:没事,你口干舌燥,他不一定会看,
投递小鹏汽车等公司9个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务