Advertisement
Infiniti_Inter

Ira

Dec 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. #include<stdio.h>
  4. #include <math.h>
  5. using namespace std;
  6. template <typename X>
  7. inline X abs(const X &a) { return a < 0 ? -a : a; }
  8.  
  9. int count_words[1000];
  10. int main()
  11. {
  12.     string a[1000];
  13.     string s, t = "";
  14.     getline(cin, s);
  15.     char g; cin >> g;
  16.     g = tolower(g);
  17.     int cnt = 0;
  18.     for (int i = 0; i < s.length(); ++i) {
  19.         char c = s[i];
  20.         if (isspace(c) || ispunct(c))
  21.         {
  22.             a[cnt++] = t;
  23.             t = "";
  24.         }
  25.         else
  26.             t += c;
  27.     }
  28.     for (int i = 0; i < cnt; ++i)
  29.         if (tolower(a[i][0]) == g )
  30.             cout << a[i] << '\n';
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement