#include <iostream>
#include <sstream>
using namespace std;
#include <string>
#include<istream>
int main() {
string str;
getline(cin, str);
int num;
string str2;
bool flag = true;
istringstream is(str);
int cnt = 0;
while (getline(is, str2, '.')) {
if (str2 != "") {
num = stoi(str2);
if (num < 0 || num > 255 || str2[0] == '+' ||(str2[0] == '0' && str2.size()!=1)) {
flag = false;
}
}
else{
flag = false;
}
cnt++;
}
if (cnt != 4) {
flag = false;
}
if (flag) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
纯纯的坑题,要注意‘+’和“01”“.1.1.1”这样的存在

京公网安备 11010502036488号