#include<iostream> #include<string> #include<vector> using namespace std; int main() { vector<int> vec1={0,0,1,1,2,3,5,8}; vector<int> vec2={5,8}; decltype(vec1.size()) j=0,m=0; for(decltype(vec1.size()) i=0;i<vec1.size();++i) { m=i; j=0; while(j<vec2.size()) { if(vec1[i]==vec2[j]) { i++; j++; } else { break; } } if(j==vec2.size()) { break; } i=m; } if(j==vec2.size()) { cout<<"true"<<endl; } else cout<<"false"<<endl; return 0; }
运行结果: