shushus

Спринт 5. Поиск в неотсортированном векторе.

Dec 10th, 2022
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. void PrintSpacesPositions(string& str) {
  7.     // напишите реализацию
  8.     auto start = find(begin(str), end(str), ' ');;
  9.     while(start!=end(str)){
  10.         cout << distance(begin(str), start) << endl;
  11.         start = find(next(start),end(str), ' ');
  12.     }
  13. }
  14. int main() {
  15.     string str = "He said: one and one and one is three"s;
  16.     PrintSpacesPositions(str);
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment