#include <iostream> #include <string> using namespace std; int main() { string s; int tep, flag; string str; while ((cin >> s)) { int len = s.size(); int p = 0, j = 0; flag = 1; for (int i = 0; i < 4; i++) { tep = 0; while (s[j] != '.' && j < len)j++; str = s.substr(p, j - p); int r = 0; for (int i1 = 0; i1 < j - p; i1++) { if (i1 == 0)r = 1; else r = 10 * r; //tep += (str[j - 1 - i1] - '0') * r;//截取下来的字串是新串,不是旧串 tep += (str[j - p-1 - i1] - '0') * r; } if (tep < 0 || tep>255) { flag = 0; break; } p = ++j;//j++则p没有加; } if (flag == 0) { cout << "No!" << endl; } else { cout << "Yes!" << endl; } } } // 64 位输出请用 printf("%lld")