标签:line def bst cin using return turn lin wap
#include<iostream>
#include<string>
using namespace std;
int main()
{
string k;
getline(cin,k);//以回车符结束输入字符串
//cin>>k;
cout<<k<<endl;
string a("abcdefghij");
string b("klmnopq");
int len = a.length();// 求长度
cout<<a<<endl;
string c=a.substr(3,10);//取子串
cout<<c<<endl;
cout<<a<<endl;
int n=a.find(c);//查找c的首字符在a中第一次出现的位置
cout<<n<<endl;
cout<<a<<endl;
cout<<b<<endl;
a.append(b);//b添在a的尾部
cout<<a<<endl;
int i=a.compare(a);//比较两个string类,同0非-1
cout<<i<<endl;
cout<<a<<endl;
a.insert(3,b);//将b插入到a的第4位
cout<<a<<endl;
a.swap(b);//交换ab
cout<<a<<endl;
cout<<b<<endl;
a.assign(b);//将b赋值给a
cout<<a<<endl;
cout<<b<<endl;
return 0;
}
标签:line def bst cin using return turn lin wap
原文地址:http://www.cnblogs.com/ur10ser/p/7883854.html