#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int main(){
string input;
cin>>input;
int k = 0;
int location[4] = {0};
int flag = 1;
for(int i = 0; i < input.length(); i++){
if(input[i] == '.') location[k++] = i;
}
if(k != 3){
cout<<"NO"<<endl;
return 0;
}
int tmposition = 0;
for(int i = 0; i < 3; i++){
int position = location[i];
string str = input.substr(tmposition, position - tmposition);
int intIP = atoi(str.c_str());
if( intIP < 0 || intIP > 255){
cout<<"NO"<<endl;
return 0;
}
tmposition = position + 1;
}
string str = input.substr(location[2]);
int intIP = atoi(str.c_str());
if( intIP < 0 || intIP > 255){
cout<<"NO"<<endl;
return 0;
}
cout<<"YES"<<endl;
return 0;
}
合法IP
最新推荐文章于 2023-02-02 21:32:18 发布