[c] миша

Viewer

copydownloadembedprintName: миша
  1. #include <iostream>
  2. #include <sstream>
  3. using namespace std;
  4.  
  5. bool
  6. rep (std::string str)
  7. {
  8.   int count = 0;
  9.   for (size_t i = 0; i < str.length (); i++)
  10.     {
  11.       size_t pos = str.rfind (str[i]);
  12.       if (pos == i){
  13.           count++;
  14.             }
  15.     }
  16.   if (count == str.length ())
  17.     {
  18.         cout << "В слове " << str <<" нет повторений \n";
  19.       return true;
  20.     }
  21.   else
  22.     {
  23.       return false;
  24.     }
  25. }
  26.  
  27. int
  28. main ()
  29. {
  30.   string str, word;
  31.   int size, count = 0;
  32.   cout << "Введите текст для проверки слов: ";
  33.   getline (cin, str);
  34.   stringstream words (str);
  35.   while (words >> word)
  36.   {
  37.     size = word.size ();
  38.  
  39.     if (rep (word))
  40.       {
  41.         count++;
  42.       }
  43.   }
  44.  
  45.   cout << "\nВ этом тексте было найдено " << count <<
  46.     " слов(а) без повторяющихся букв." << endl;
  47.  
  48.   return 0;
  49. }
  50.  
  51.  

Editor

You can edit this paste and save as new:


File Description
  • миша
  • Paste Code
  • 21 Jan-2021
  • 924 Bytes
You can Share it: