Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- bool isDigit(char c);
- int isRight(string s);
- int main()
- {
- string IP;
- cin >> IP;
- cout << isRight(IP);
- return 0;
- }
- bool isDigit(char c)
- {
- return '0' <= c && c <= '9';
- }
- int isRight(string s)
- {
- int len = s.size(), sum = 0;
- for (int i = 1; i < len - 1; i++);
- {
- if (s[i] == '.')
- {
- if (!(isDigit(s[i + 1]) && isDigit(s[i - 1]))) return 0;
- sum++;
- }
- }
- if (sum != 3) return 0;
- else return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement