substring chain

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <string> using namespace std; int main() { string x; cin >> x; // input simulado = banana.batata.tomato.buzz.fuzz.chuzz.bop.nop.chuck size_t found = x.find("."); while (found != std::string::npos){ //loop enqunato encontrar "." na string cout << x.substr(0,x.find(".")) << endl;// acha a primeira parte x = x.substr(x.find(".")+1); // atribui ao x o resto da string found = x.find("."); //grava a posição que o "." esta } cout << x << endl;// printa a ultima parte da string (que não tem ".") return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines