Advertisement
mostlabs

13/2

Apr 24th, 2020
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string text, word;
  9.  
  10.     cout << "Enter text: " << endl;
  11.     getline(cin, text);
  12.  
  13.     stringstream words(text);
  14.     while (words >> word)
  15.     {
  16.         int c = 1;
  17.         int t = 1;
  18.         if (word.find_first_of(text) != string::npos)
  19.         {
  20.  
  21.             cout << word << endl;
  22.  
  23.             for (int i = 0; i < word.length(); i++) {
  24.                 if (word[0] == word[i + 1]) {
  25.                     c++;
  26.                    
  27.                     t = c;
  28.                 }
  29.  
  30.  
  31.             }
  32.             cout << t;
  33.             cout << endl;
  34.         }
  35.  
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement