string类与getline(cin,str)函数


题目详情

题解与和知识点

getline(cin,str)输入一行
直接cin>>str只能接收空格之前的字符串。

#include 
#include 
#include 
using namespace std;
int main() 
{
    string str;        //Declare a string 
    getline(cin,str);  //Input a line
    reverse(str.begin(),str.end()); //reverse函数功能是逆序(或反转),多用于字符串、数组、容器。头文件是#include 
    cout<