6.3w+
社区成员
#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(),'\n'); // <-----这里
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>
using namespace std;
int main()
{
vector <int> ivec;
list <int> ilst;
int ival;
cout <<"the vetor's numbers" <<endl;
while(cin>>ival)
ivec.push_back(ival);
cin.clear();//<=========增加这个
cout <<"the list's numbers" <<endl;
while(cin>> ival)
ilst.push_back(ival);//<=========容器写错了
cin.clear();
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>
using namespace std;
int main()
{
vector <int> ivec;
list <int> ilst;
int ival;
cout <<"the vetor's numbers" <<endl;
while(cin>>ival)
ivec.push_back(ival);
cin.clear();//<=========增加这个
cout <<"the list's numbers" <<endl;
while(cin>> ival)
ilst.push_back(ival);//<=========容器写错了
cin.clear();
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>
using namespace std;
int main()
{
vector <int> ivec;
list <int> ilst;
int ival;
cout <<"the vetor's numbers" <<endl;
while(cin>>ival)
ivec.push_back(ival);
cin.clear();//<=========增加这个
cout <<"the list's numbers" <<endl;
while(cin>> ival)
ilst.push_back(ival);//<=========容器写错了
cin.clear();
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>
using namespace std;
int main()
{
vector <int> ivec;
list <int> ilst;
int ival;
cout <<"the vetor's numbers" <<endl;
while(cin>>ival)
ivec.push_back(ival);
cin.clear();//<=========增加这个
cout <<"the list's numbers" <<endl;
while(cin>> ival)
ilst.push_back(ival);//<=========容器写错了
cin.clear();
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>
using namespace std;
int main()
{
vector <int> ivec;
list <int> ilst;
int ival;
cout < <"the vetor's numbers" < <endl;
while(cin> > ival)
ivec.push_back(ival);
cin.clear(); //记得把输入流清空下
cout < <"the list's numbers" < <endl;
while(cin> > ival)
ilst.push_back(ival); //这里的ivec.push_back(ival); 写错了
cin.clear();
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>
using namespace std;
int main()
{
vector <int> ivec;
list <int> ilst;
int ival;
cout <<"the vetor's numbers" <<endl;
while(cin>>ival)
ivec.push_back(ival);
cin.clear();//<=========增加这个
cout <<"the list's numbers" <<endl;
while(cin>> ival)
ivec.push_back(ival);
cin.clear();
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;
}