#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <iterator>
#include <list>
using namespace std;
bool comparelv(list<int> & lint, vector <int> & vint)
{
auto ibegin=lint.begin();
auto vbegin=vint.begin();
if (vint.size() == lint.size())
{
while (ibegin != lint.end())
{
if (*ibegin != *vbegin)
{
return false;
}
++ibegin;
++vbegin;
}
return true;
}
else
{
return false;
}
}
int main()
{
list <int> lint={1,2,3,4,5,6};
vector <int> vint={1,2,3,4,5,6,7};
if(comparelv(lint,vint))
cout<<"equal"<<endl;
else
cout<<"not equal"<<endl;
system("pause");
return 0;
}
C++primer第5版课后练习习题答案9.16
最新推荐文章于 2021-10-24 23:04:27 发布