qq_40376800
云梦尘
2017-10-23 13:21

大佬们,自己写的一个小程序 怎么不对呀

  • c++

#include
#include
#include
#include
using namespace std;
list list1;
deque deque1;
deque deque2;
deque deque3;
void read()
{
int num;
while (cin >> num)
list1.push_back(num);

}
void judge()
{
list::iterator it1=list1.begin();
for ( it1; it1 !=list1.end(); it1++)
{

if ((*it1)%2==0)
{
deque1.push_back(*it1);

    }
    else
    {
        deque2.push_back(*it1);
    }
}

}
void main()
{
read();
judge();
deque::iterator it2 = deque1.begin();
deque::iterator it3 = deque2.begin();
cout << "偶数为:";
for (it2; it2 != deque1.end();it2++)
{
cout << *it2 << " ";
}
cout << endl;
cout << "奇数为:";
for (it3; it3 != deque2.end(); it3++)
{
cout << *it3 << " ";
}
cout << endl;
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答

为你推荐

换一换