You are viewing a single comment's thread. Return to all comments →
CPP Code:
void separateNumbers(string s) { if (0 == s.size() || 1 == s.size() || '0' == s[0]) { std::cout << "NO" << std::endl; return; } for (int i{1}; i < s.size(); i++) { auto startingNumber{std::atol(s.substr(0, i).c_str())}; std::string newString{s.substr(0, i)}; while (newString.size() < s.size()) { newString += std::to_string(++startingNumber); } if (newString == s) { std::cout << "YES " << s.substr(0, i) << std::endl; return; } } std::cout << "NO" << std::endl; }
Seems like cookies are disabled on this browser, please enable them to open this website
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
CPP Code: