对于string类:
这个是输入2个字符串,换行结束
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
vector<string> arr;
string mystr;
int k = 2;
while (k--)
{
getline(cin, mystr);
arr.push_back(mystr);
}
for (auto c : arr)
cout << c << endl;
system("pause");
return 0;
}
记录一下
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
string s;
cin >> s;
while (getline(cin, s))
{
}
cout << s << endl;
vector<string> arr;
string mystr;
int k = 2;
while (k--)
{
getline(cin, mystr);
arr.push_back(mystr);
}
int q = 0;
cin >> q;//q代表询问次数
vector<vector<int>> query;//query代表询问的数组,
int i = 0, j = 0;
for (int k = 0;k < q;k++)
{
cin >> i >> j;
query.push_back({ i,j });//均为整数
}
string a, b;
int cnt1 = 0, cnt2 = 0;// 分别统计到子串的元素个数
for (int k = 0;k < q;k++)
{
i = query[k][0]-1;
j = query[k][1]-1;
}
//for (auto c : query)
//cout << c[0] << " " << c[1] << endl;
system("pause");
return 0;
}