Advertisement
Kentoo

A#3

Nov 27th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include "windows.h"
  5.  
  6. using namespace std;
  7. void main()
  8. {
  9.     int k1 = 0, k2 = 0, k3 = 0;
  10.     setlocale(LC_ALL, "Russian");
  11.     SetConsoleCP(1251);
  12.     SetConsoleOutputCP(1251);
  13.     string str;
  14.     cout << "Введите текст" << endl;
  15.     getline(cin, str);
  16.     while (str.find("...") != string::npos) {
  17.         str.replace(str.find("..."), 3, ".");
  18.     }
  19.     while (str.find(".") != string::npos) {
  20.         str.replace(str.find("."), 3, "");
  21.         k1++;
  22.     }
  23.     while (str.find("!") != string::npos) {
  24.         str.replace(str.find("!"), 3, "");
  25.         k2++;
  26.     }
  27.     while (str.find("?") != string::npos) {
  28.         str.replace(str.find("?"), 3, "");
  29.         k3++;
  30.     }
  31.     cout << "Количество повествовательных предложений : " << k1 << endl
  32.         << "Количество вопросительных предложений : " << k2 << endl
  33.         << "Количество восклицательных предложений : " << k3 << endl;
  34.     system("pause");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement