artemgf

SMS

Oct 30th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <string>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <map>
  8. #include <queue>
  9. #include <set>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     string SMS;
  16.     int N, M;
  17.     cin >> N >> M;
  18.     bool Mgood = true;
  19.     int num = 0;
  20.     getline(cin, SMS);
  21.     getline(cin, SMS);
  22.     int answ = 1;
  23.     for(int i=0;i<=SMS.size()-1;i++)
  24.     {
  25.         if (SMS[i] != ' ' && ((SMS[i]<'A' || SMS[i]>'Z') && (SMS[i]<'a' || SMS[i]>'z')))
  26.             Mgood = false;
  27.         if (Mgood)
  28.         {
  29.             if (num >= M)
  30.             {
  31.                 answ ++;
  32.                 num = 1;
  33.             }
  34.             else
  35.                 num++;
  36.         }
  37.         else
  38.         {
  39.             if (num >= N)
  40.             {
  41.                 Mgood = !(SMS[i] != ' ' && ((SMS[i]<'A' || SMS[i]>'Z') && (SMS[i]<'a' || SMS[i]>'z')));
  42.                 answ ++;
  43.                 num =1;
  44.             }
  45.             else
  46.                 num++;
  47.         }
  48.     }
  49.  
  50.     cout << answ;
  51.     system("pause");
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment