文章
25
粉丝
0
获赞
140
访问
4.1k
#include<bits/stdc++.h>
using namespace std;
//判断ip地址是否合法
bool isValid(string s){
int count = 0; //记录中间.的个数
string num; //记录点中间的数字
for(int i = 0;i<s.length();i++){
if(s[i] == '.' || i == s.length()){//走到了.或者最后一位
//1.两点之间为空,不合法
if(num.empty())
return false;
//2.有前导0,不合法
if(num.length()>1 && num[0] == 0)
return false;
//3.num中有非数字,不合法
...
登录后发布评论
暂无评论,来抢沙发