brospresident

Untitled

Oct 14th, 2021
580
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. bool isValidWord(string word, string A, string B) {
  7.     return tolower(A[0]) == tolower(word[0]) && tolower(B[0]) == tolower(word[word.length() - 1]);
  8. }
  9.  
  10. int main () {
  11.     int M, N;
  12.     string A, B;
  13.     cin >> A >> B >> M >> N;
  14.  
  15.     string cuvant;
  16.     int lower = 0, medium = 0, larger = 0;
  17.     while (cin >> cuvant) {
  18.         if (isValidWord(cuvant, A, B)) {
  19.             if (cuvant.length() < M) lower++;
  20.             else if (cuvant.length() >= M && cuvant.length() < N) medium++;
  21.             else if (cuvant.length() >= N) larger++;
  22.         }
  23.     }
  24.  
  25.     cout << lower << " " << medium << " " << larger << endl;
  26.  
  27.     return 0;
  28. }
RAW Paste Data