一道很基础的C++题目,。大家帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/08 14:41:17
given that the string variables str1 and str2 contain
"you ought to start with logic"
and
"ou"
respectively,what is the result of each of the following expressions?
a. str1.length()
b. str1.find(str2)
c. str1.substr(4,25)
d. str1.substr(4,25).find(str2)
e. str1.substr.(str1.find("logic"),3)
f. str1.substr(24,5).find(str2.sbystr(0,1))
g. str1.find("end")

这你都问, 自己在电脑里输了看结果就行了
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str1("you ought to start with logic"),str2("ou");
cout<<str1.length()<<endl;
cout<<str1.find(str2)<<endl;
cout<<str1.substr(4,25)<<endl;
cout<<str1.substr(4,25).find(str2)<<endl;
cout<<str1.substr.(str1.find("logic"),3)<<endl;
cout<<str1.substr(24,5).find(str2.sbystr(0,1))<<endl;
cout<<str1.find("end")<<endl;
}

能不能写中文啊!!!英语很烂啊!!e吧!!