#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <regex>
using namespace std;
vector<string> split(const string& line, const char delim) {
stringstream ss(line);
vector<string> tokens;
string token;
while (getline(ss, token, delim)) {
tokens.push_back(token);
}
return tokens;
}
vector<unsigned> strings_to_int(const vector<string>& box) {
vector<unsigned> res;
for (const auto& x : box) {
if (regex_match(x, regex("\\d{1,3}"))) {
res.push_back(stoul(x));
}
}
return res;
}
bool is_ip_v4(const string& ip) {
static const auto max = 255U;
auto tokens = split(ip, '.');
if (tokens.size() != 4) {
return false;
}
auto octets = strings_to_int(tokens);
for (auto octet : octets) {
if (octet > max) {
return false;
}
}
return true;
}
int main() {
string ip;
cin >> ip;
if (is_ip_v4(ip)) {
auto tokens = split(ip, '.');
auto octets = strings_to_int(tokens);
for (auto octet : octets) {
cout << octet << ' ';
}
} else {
cout << "Error: incorrect ip address!";
}
puts("");
system("pause > nul");
}
