关于VS2005的基础编程问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 02:45:17
1.编写一个控制台应用程序,它接收用户输入的一个字符串,将其中的字符以与输入相反的顺序输出.

这么简单?甚至不太像是一个作业.

#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
int _tmain(int argc, _TCHAR* argv[])
{
std::string str;
std::cout << "input a string:" << std::endl ;
std::cin >> str ;
std::vector<char> vs2( str.c_str(), str.c_str()+str.size() );
std::reverse( vs2.begin(), vs2.end() );
std::cout << &vs2[0] << std::endl ;
system("pause");
return 0;
}