PhotoShaman

сэйв

Mar 5th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void main()
  8. {
  9.     string line;
  10.     ifstream Fin; // поток ввода
  11.     ofstream Fout; // поток вывода
  12.     Fin.open("C:\\Users\\User\\Desktop\\text.txt");
  13.     Fout.open("C:\\Users\\User\\Desktop\\OutputText.txt");
  14.     char symbol = 'а';
  15.     int withoutThatSymbol = 0, currentPosition;
  16.  
  17.     while (getline(Fin, line))
  18.     {
  19.         currentPosition = 0;
  20.         withoutThatSymbol++;
  21.         while (line[currentPosition] == ' ' && line[currentPosition] != '\0')
  22.             currentPosition++; //Проходит пробелы в начале строки
  23.         while (line[currentPosition] != '\0')
  24.         {
  25.             if (line[currentPosition] == symbol)
  26.             {
  27.                 withoutThatSymbol--;
  28.                 break;
  29.             }
  30.             currentPosition++;
  31.         }
  32.     }
  33.     Fout << withoutThatSymbol << endl;
  34.     cout << withoutThatSymbol << endl;
  35.     Fin.close();
  36.     Fout.close();
  37.     cin.get(); cin.get();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment