Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- fstream f;
- f.open("numbers.txt",ios::in);
- if(!f)
- {
- cout << "Error opening file...\n";
- return 0;
- }
- int x, n=0;
- while(f >> x)
- ++n;
- f.close();
- fstream f1("numbers.txt",ios::in);
- int *mas;
- mas = new int[n];
- int i=0;
- while(f1 >> mas[i++]);
- sort(mas,mas+n);
- f1.close();
- f1.open("numbers.txt",ios::out);
- for(i=0; i<n; ++i)
- f1 << mas[i] << ' ';
- f1.close();
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement