Raslboyy

Untitled

May 29th, 2021
1,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <codecvt>
  4. #include <string>
  5. #include <sstream>
  6. #include <locale>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11.  
  12.   wifstream fin("stroka_3.txt");
  13.   wstring A[20];
  14.   int n = 0;
  15.   while (getline(fin, A[n]))
  16.     n++;
  17.  
  18.   cout << "Построчный вывод из файла:" << endl;
  19.   for (int i = 0; i < n; i++) {
  20.  
  21.     wcout << "Строка " << i << " -> " << A[i] << endl;
  22.     cout << '\t' << "Количество символов = " << A[i].size() << endl;
  23.  
  24.     int count = 1;
  25.     for (int j = 0; j < A[i].size() - 1; j++)
  26.       if (A[i][j] == ' ' && A[i][j + 1] != ' ')
  27.         count++;
  28.  
  29.     cout << '\t' << "Количество слов = " << count << endl;
  30.   }
  31.   cout << "Всего строк -> " << n << endl;
  32.  
  33.   return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment