kutuzzzov

Спринт 4. Урок 2. Поиск в несортированном векторе

Dec 27th, 2021 (edited)
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iterator>
  5.  
  6. using namespace std;
  7.  
  8. void PrintSpacesPositions(string& str) {
  9.     for (string::size_type pos = 0; (pos = str.find(' ', pos)) != string::npos; ++pos) {
  10.         cout << pos << endl;
  11.     }
  12. }
  13. int main() {
  14.     string str = "He said: one and one and one is three"s;
  15.     PrintSpacesPositions(str);
  16.     return 0;
  17. }
Add Comment
Please, Sign In to add comment