题解 | #合法IP#
合法IP
http://www.nowcoder.com/practice/995b8a548827494699dc38c3e2a54ee9
利用cin对不同类型的输入方式来分隔字符
#include<bits/stdc++.h>
using namespace std;
int main()
{
int num1,num2,num3,num4;
char p;
while(cin>>num1>>p>>num2>>p>>num3>>p>>num4)
{
if(num1>=0&&num1<=255&&num2>=0&&num2<=255&&num3>=0&&num3<=255&&num4>=0&&num4<=255)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}