Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <stack>
- #include <queue>
- #include <list>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- // input.txt : 1 -5 2 3 -4 51 -14 -24 1 5
- int main()
- {
- list<int> l;
- while (in.peek() != EOF)
- {
- int cur; in >> cur;
- l.push_back(cur);
- }
- list<int> ans;
- list<int> temp;
- out << "result : ";
- while (!l.empty())
- {
- int cur = l.front(); l.pop_front();
- if (cur > 0)
- {
- ans.push_back(cur);
- out << cur << ' ';
- }
- else
- temp.push_back(cur);
- }
- while (!temp.empty())
- {
- int cur = temp.front(); temp.pop_front();
- out << cur << ' ';
- ans.push_back(cur);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement