#include <iostream>
#include <string>
#include <vector>
std::vector<int> obter_posicoes(std::string texto, std::string elemento){
std::vector<int> posicoes;
std::size_t posicao = texto.find(elemento);
while (posicao!=std::string::npos){
posicoes.push_back(posicao);
posicao = texto.find("(",posicao+1);
}
return posicoes;
}
int main ()
{
std::string texto ("Na(CO5(Pt");
std::vector<int> posicoes = obter_posicoes(texto, "(");
for (auto posicao : posicoes){
std::cout<<posicao<< " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RkOjp2ZWN0b3I8aW50PiBvYnRlcl9wb3NpY29lcyhzdGQ6OnN0cmluZyB0ZXh0bywgc3RkOjpzdHJpbmcgZWxlbWVudG8pewogICAgc3RkOjp2ZWN0b3I8aW50PiBwb3NpY29lczsKICAgIHN0ZDo6c2l6ZV90IHBvc2ljYW8gPSB0ZXh0by5maW5kKGVsZW1lbnRvKTsKCiAgICB3aGlsZSAocG9zaWNhbyE9c3RkOjpzdHJpbmc6Om5wb3MpewogICAgICAgIHBvc2ljb2VzLnB1c2hfYmFjayhwb3NpY2FvKTsKICAgICAgICBwb3NpY2FvID0gdGV4dG8uZmluZCgiKCIscG9zaWNhbysxKTsKICAgIH0KCiAgICByZXR1cm4gcG9zaWNvZXM7Cn0KCmludCBtYWluICgpCnsKICAgIHN0ZDo6c3RyaW5nIHRleHRvICgiTmEoQ081KFB0Iik7CiAgICBzdGQ6OnZlY3RvcjxpbnQ+IHBvc2ljb2VzID0gb2J0ZXJfcG9zaWNvZXModGV4dG8sICIoIik7CgogICAgZm9yIChhdXRvIHBvc2ljYW8gOiBwb3NpY29lcyl7CiAgICAgICAgc3RkOjpjb3V0PDxwb3NpY2FvPDwgIiAiOwogICAgfQoKCiAgICByZXR1cm4gMDsKfQo=