C++中字符串反转
来源:互联网 发布:闲来麻将源码 编辑:程序博客网 时间:2024/04/27 15:20
这段时间,几乎每天都在看C++ Primer Plus,这本书写的确实还不错,适合新手入门学习,他给了我很多的启发,今天在书里看到如何将一个字符串反转,自己索性写了写代码,来实现这个功能。
下面是代码演示:
#include <iostream>#include <string>using namespace std;int main(){string str;cin >> str;int length = str.length();for (int i = 0; i < length/2;i++){char temp= str[i];str[i] = str[length - 1 - i];str[length - 1 - i] = temp;}cout << "str反转之后:" << str << endl;}
0 0
- c语言中关于字符串反转问题
- 字符串反转(C/C++)
- 反转字符串----(c#)
- C字符串反转算法
- (C#)字符串反转
- C语言字符串反转
- 字符串反转reverse.c
- C 字符串反转
- 字符串反转(C语言)
- C语言字符串反转
- C语言字符串反转
- C字符串操作:字符串反转
- 字符串中单词反转
- 字符串中单词反转
- C++中字符串反转
- 字符串中 单词反转
- Java中字符串反转
- java中字符串反转
- 第六二八章 在武力上面威慑对方!
- 冒泡排序
- 通过PageFactory避免WebElement过期
- 资料汇总篇
- flashback之flashback table
- C++中字符串反转
- 【 整数划分 - 问题 】
- Mac系统下安装ant
- nginx介绍(一) 简介篇
- strlen(),strcpy(),strncpy(),strcat(),strncat(),strcmp(),strncmp()等函数的实现
- valueable document
- 一个密码怎样改变了我的人生
- PE文件结构(四) 输出表
- Ubuntu 14.04 为 root 帐号开启 SSH 登录