Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- typedef long long ll;
- typedef vector<ll> vll;
- ll i, j;
- string str;
- vll dot, param;
- string check()
- {
- if (param.size() != 4) return "Bad";
- for (i = 0; i < 4; i++) if (dot[i + 1] - dot[i] == 1) return "Bad";
- for (i = 0; i < 4; i++) if (param[i] > 255) return "Bad";
- return "Good";
- }
- int main()
- {
- getline(cin, str);
- dot.push_back(-1);
- for (i = 1; i < str.length() - 1; i++) if (str[i] == '.') dot.push_back(i);
- dot.push_back(str.length());
- if (dot.size() == 5)
- {
- for (i = 0; i < 4; i++)
- {
- param.push_back(0);
- for (j = dot[i] + 1; j < dot[i + 1]; j++) param[i] = param[i] * 10 + str[j] - 48;
- }
- }
- cout << check() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement