#include
"
stdafx.h
"
#include < iostream >
#include < list >
#include < vector >
#include < limits >
using namespace std;
int main( void )
... {
vector <int> ivec;
list <int> ilst;
int ival;
cout << "the vetor's numbers" << endl;
while(cin >> ival)
ivec.push_back(ival);
cin.clear(); //注意此处
cin.ignore(std::numeric_limits<streamsize>::max(),' ');//此处关键
cout << "the list's numbers" << endl;
while(cin >> ival)
ilst.push_back(ival);
vector <int> ::const_iterator vecit = ivec.begin();
list <int> ::const_iterator lstit = ilst.begin();
if(ilst.size() != ivec.size())
...{
cout << "they are not same" << endl;
return 0;
}
else
...{
for( ; vecit != ivec.end(), lstit != ilst.end(); ++vecit, ++lstit)
...{
if(*vecit != *lstit)
...{
cout << "they are not same" << endl;
return 0;
}
}
cout << "they are same!" << endl;
}
return 0;
}
#include < iostream >
#include < list >
#include < vector >
#include < limits >
using namespace std;
int main( void )
... {
vector <int> ivec;
list <int> ilst;
int ival;
cout << "the vetor's numbers" << endl;
while(cin >> ival)
ivec.push_back(ival);
cin.clear(); //注意此处
cin.ignore(std::numeric_limits<streamsize>::max(),' ');//此处关键
cout << "the list's numbers" << endl;
while(cin >> ival)
ilst.push_back(ival);
vector <int> ::const_iterator vecit = ivec.begin();
list <int> ::const_iterator lstit = ilst.begin();
if(ilst.size() != ivec.size())
...{
cout << "they are not same" << endl;
return 0;
}
else
...{
for( ; vecit != ivec.end(), lstit != ilst.end(); ++vecit, ++lstit)
...{
if(*vecit != *lstit)
...{
cout << "they are not same" << endl;
return 0;
}
}
cout << "they are same!" << endl;
}
return 0;
}