标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8633 Accepted Submission(s): 1706
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 using namespace std; 5 6 int main() 7 { 8 char a[2000]; 9 while(gets(a)!=NULL) 10 { 11 int point=0,numm=0,sum=0,flag=1,len=strlen(a),ok=1; 12 a[len]=‘.‘; 13 for(int i=0;i<=len;i++) 14 { 15 if(isdigit(a[i])) 16 { 17 ok=0; 18 sum=sum*10+(a[i]-‘0‘); 19 numm++; 20 } 21 else if(a[i]==‘.‘) 22 { 23 if(sum<0||sum>255) {flag=0;break;} 24 if(numm<=0||numm>=4) {flag=0;break;} 25 point++; 26 sum=0;numm=0; 27 } 28 else if(a[i]==‘ ‘&&!ok) {flag=0;break;} 29 else if(a[i]!=‘ ‘) {flag=0;break;} 30 } 31 point--; 32 if(point==3&&flag) cout<<"YES"<<endl; 33 else cout<<"NO"<<endl; 34 } 35 }
标签:
原文地址:http://www.cnblogs.com/wsaaaaa/p/4296578.html