Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- void PrintSpacesPositions(string& str) {
- for(auto i = find(str.begin(), str.end(), ' '); // поиск первого пробела {от начала до первого сопадения}
- i != str.end(); // ищем пока не дойдём до конца строки
- i = find(next(i), str.end(), ' ')) // переходим на следующий пробел, если это не конец строки.
- {
- cout << distance(str.begin(), i) << endl; // выводим диапазон от начала до пробела.
- }
- }
- int main() {
- string str = "He said: one and one and one is three"s;
- PrintSpacesPositions(str);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement