SHARE
TWEET

Untitled

a guest Apr 21st, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     char a;
  10.     vector <int> vec;
  11.     int b;
  12.     int i = 0;
  13.     ifstream fin;
  14.     ofstream fout;
  15.     fin.open("in.txt");
  16.     while(!fin.eof())
  17.     {
  18.         a = fin.get();
  19.         b = a - 48;
  20.         vec.push_back(b);
  21.         i++;
  22.     }
  23.     for ( i = 0; i < vec.size() - 1; i++)
  24.     {
  25.         cout << vec[i];
  26.     }
  27.     fin.close();
  28.     cout << endl;
  29.     for (i = 0; i < vec.size() - 1; i++)
  30.     {
  31.         for (int j = 0; j < vec.size() - 2; j++)
  32.         {
  33.             if(vec[j] >vec[j+1])
  34.             {
  35.                 b = vec[j];
  36.                 vec[j] = vec [j+1];
  37.                 vec[j+1] = b;
  38.             }
  39.         }
  40.     }
  41.     for ( i = 0; i < vec.size() - 1; i++)
  42.     {
  43.         cout << vec[i];
  44.     }
  45.     fout.open("out.txt");
  46.     for ( i = 0; i < vec.size() - 1; i++)
  47.     {
  48.         fout << vec[i];
  49.     }
  50.     fout.close();
  51.     system("PAUSE");
  52.     return 0;
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top