- #include <algorithm>
- #include <vector>
- #include <string>
- #include <iostream>
- #include <numeric>
- #include <iterator>
- #include <sstream>
- #include <list>
- #include <fstream>
- using namespace std;
- bool bind(const int i,const int j)
- {
- if(i%2==0 && j%2!=0)
- return true;
- else
- return false;
- }
- bool bind2(const int i)
- {
- return i%2!=0;
- }
- int main(int argc,char ** argv)
- {
- istream_iterator<int> in_iter(cin);
- std::istream_iterator<int> eof;
- std::fstream ofile("oResult.txt",ios::out );
- std::ostream_iterator<int> oddfile(ofile," ");
- std::fstream sfile("sResult.txt",ios::out);
- std::ostream_iterator<int> evenfile(sfile,"/n");
- vector<int> vec(in_iter,eof);
- stable_sort(vec.begin(),vec.end(),bind);
- vector<int>::iterator mid=find_if(vec.begin(),vec.end(),bind2);
- vector<int>::iterator iter=vec.begin();
- copy(vec.begin(),mid,oddfile);
- copy(mid,vec.end(),evenfile);
- return 0;
- }
C++ primer 11.18
最新推荐文章于 2024-10-30 21:53:27 发布