Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <clocale>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     setlocale(LC_ALL, "");
  11.     int k = 0;
  12.     string s;
  13.     ifstream f;
  14.     ofstream f1, f2;
  15.     f1.open("C:\\SHP\\Парапапам\\2.txt");
  16.     f2.open("C:\\SHP\\Парапапам\\3.txt");
  17.     f.open("C:\\SHP\\Парапапам\\1.txt");
  18.    
  19.     while (!f.eof())
  20.     {
  21.         getline(f, s);
  22.         cout << s << endl;
  23.         for (int i = 0; i < s.size() - 2; i++)
  24.         {
  25.             if (s.at(i) == ' ' && s.at(i + 1) == ' ')
  26.             {
  27.                 s.erase(i, 1);
  28.                 i--;
  29.             }
  30.         }
  31.  
  32.         if (s.at(s.size() - 1) == ' ')
  33.         {
  34.             s.erase(s.size() - 1, 1);
  35.         }
  36.         if (s.at(0) == ' ')
  37.         {
  38.             s.erase(0, 1);
  39.         }
  40.  
  41.         cout << s;
  42.     }
  43.  
  44.    
  45.  
  46.     f.close();
  47.     f1.close();
  48.     f2.close();
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement