//编写程序判断一个vector<int>容器所包含的元素是否与一个list<int>容器的完全相同
# include<iostream>
# include<vector>
# include<list>
using namespace std;
void main()
{
vector<int> a;
list<int> b;
int x,y;
cout<<"please input some integers for a:";
while(cin>>x)
{
if(x==999) break;
a.push_back(x);
}
cout<<"please input some integers for b:";
while(cin>>y)
{
if(y==888)break;
b.push_back(y);
}
cout<<"The vector a is:";
for(vector<int>::iterator it=a.begin();it!=a.end();it++)
cout<<*it<<" ";
cout<<endl;
cout<<"The list b is:";
for(list<int>::iterator it1=b.begin();it1!=b.end();it1++)
cout<<*it1<<" ";
cout<<endl;
bool same=true;
if(a.size()!=b.size())
same=false;
else
{
vector<int>::iterator m=a.begin();
list<int>::iterator n=b.begin();
while(m!=a.end())
{
if((*m)!=(*n))
{
same =false;
break;
}
else
{
m++;
n++;
}
}
}
if(same)
cout<<"They are the same!"<<endl;
else
cout<<"They are defferent!"<<endl;
}
# include<iostream>
# include<vector>
# include<list>
using namespace std;
void main()
{
vector<int> a;
list<int> b;
int x,y;
cout<<"please input some integers for a:";
while(cin>>x)
{
if(x==999) break;
a.push_back(x);
}
cout<<"please input some integers for b:";
while(cin>>y)
{
if(y==888)break;
b.push_back(y);
}
cout<<"The vector a is:";
for(vector<int>::iterator it=a.begin();it!=a.end();it++)
cout<<*it<<" ";
cout<<endl;
cout<<"The list b is:";
for(list<int>::iterator it1=b.begin();it1!=b.end();it1++)
cout<<*it1<<" ";
cout<<endl;
bool same=true;
if(a.size()!=b.size())
same=false;
else
{
vector<int>::iterator m=a.begin();
list<int>::iterator n=b.begin();
while(m!=a.end())
{
if((*m)!=(*n))
{
same =false;
break;
}
else
{
m++;
n++;
}
}
}
if(same)
cout<<"They are the same!"<<endl;
else
cout<<"They are defferent!"<<endl;
}