标签:
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; char s[11000]; int main() { while(gets(s)) { int l = strlen(s),i,j,k; bool bl = 1; for(i = 0;i<l;i++) if(!((s[i]>=‘0‘&&s[i]<=‘9‘)||s[i] == ‘.‘)) bl = 0; int num = 0; for(i = 0;i<l;i++) if(s[i] == ‘.‘) num++; if(num!=3) bl = 0; num = 0; int a; for(i = 0;i<l;i++) { a = 0; bool b = 0; while(s[i]>=‘0‘&&s[i]<=‘9‘) { b = 1; a = a*10+s[i++]-‘0‘; if(a>1000) bl = 0; } if(a>255) bl = 0; if(b) num++; } if(num!=4) bl = 0; if(bl) cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/wos1239/p/4564347.html