Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- int main()
- {
- char a;
- vector <int> vec;
- int b;
- int i = 0;
- ifstream fin;
- ofstream fout;
- fin.open("in.txt");
- while(!fin.eof())
- {
- a = fin.get();
- b = a - 48;
- vec.push_back(b);
- i++;
- }
- for ( i = 0; i < vec.size() - 1; i++)
- {
- cout << vec[i];
- }
- fin.close();
- cout << endl;
- for (i = 0; i < vec.size() - 1; i++)
- {
- for (int j = 0; j < vec.size() - 2; j++)
- {
- if(vec[j] >vec[j+1])
- {
- b = vec[j];
- vec[j] = vec [j+1];
- vec[j+1] = b;
- }
- }
- }
- for ( i = 0; i < vec.size() - 1; i++)
- {
- cout << vec[i];
- }
- fout.open("out.txt");
- for ( i = 0; i < vec.size() - 1; i++)
- {
- fout << vec[i];
- }
- fout.close();
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement