Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stack>
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("in.txt");
- ofstream fout("out.txt");
- int main() {
- setlocale(LC_ALL, "russian");
- stack<int> s,s1;
- while (fin.peek() != EOF)
- {
- int cur;
- fin >> cur;
- if (cur > 0)
- s.push(cur);
- else
- s1.push(cur);
- }
- while (!s.empty())
- {
- int cur = s.top();
- s.pop();
- fout << cur << ' ';
- }
- while (!s1.empty())
- {
- int cur = s1.top();
- s1.pop();
- fout << cur << ' ';
- }
- cout << endl;
- system("pause");
- return 0;
- fin.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement