Raslboyy

Untitled

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