挑战任务

将输入的字符串str进行反转。

编程要求

补全右侧vector<char> inversion(string str)函数实现字符串的反转并返回反转之后的字符串,其中函数参数str表示要反转的字符串。

测试说明

输入:

hello world

输出:

dlrow olleh

#ifndef _TEST
#define _TEST
#include <iostream>
#include <vector>
using namespace std; class Task{
public:
vector<char> inversion(string str){
vector <char> vec;
int index = str.length();
while(index--){
vec.push_back(str[index]);
}
return vec;
}
};
#endif

  

include <iostream>
#include <vector>
#include <stdio.h>
#include "Task.hpp" using namespace std; int main(){
string str;
getline(cin,str); Task tt;
vector <char> result;
result = tt.inversion(str);
for(int i = 0; i<str.length();i++){
cout << result[i];
}
cout << endl;
}

  

#ifndef _TEST
#define _TEST
#include <iostream>
#include <vector>
using namespace std; class Task{
public:
vector<char> inversion(string str){
vector <char> vec;
int index = str.length();
while(index--){
vec.push_back(str[index]);
}
return vec;
}
};
#endif

 

运行结果 

最新文章

  1. jQuery Ajax传递数组到asp.net web api参数为空
  2. 【转】运行java -version命令时出现错误及解决
  3. 转:MFC之COleVariant
  4. javascript提高篇+吐槽
  5. R语言分析(一)-----基本语法
  6. java原生实现屏幕设备遍历和屏幕采集(捕获)等功能
  7. php 守护进程类
  8. 关机,重启BAT命令
  9. vim编辑器的设置
  10. java开学考试有感以及源码
  11. NVIDIA 驱动安装(超详细)
  12. 自学Python3.5-字符串格式化 作用域 递归
  13. Hive QL的操作
  14. Delphi2010如何获取程序内部自身版本号?
  15. [C#]记一次解析XML转对象的笔记
  16. mahout 使用
  17. 《C陷阱与缺陷》阅读笔记(个人版)
  18. java 大文件上传 断点续传 完整版实例 (Socket、IO流)
  19. 应用程序添加角标和tabBar添加角标,以及后台运行时显示
  20. dos系统下的游戏~ 不断更新中

热门文章

  1. 四、Java web 部 分试题
  2. SecureCRT方向键不可用
  3. 04.给linux用户添加sudo权限
  4. QT,QT SDK, QT Creator 区别
  5. CSS多行文字垂直居中的两种方法
  6. setTimeout闭包常见问题
  7. 【BUG记录】记一次游戏越来越卡的BUG
  8. JavaScript 从定义到执行,你应该知道的那些事
  9. [C语言]使用数组
  10. TCP工作过程;TCP Flood的攻击的原理和现象;TCP协议设计的安全隐患与防范对策