文章
55
粉丝
100
获赞
12
访问
29.8k
#include<stdio.h>
#include<cstring>
#include<iostream>
using namespace std;
const int N = 110;
char a[4][N];
int num[4];
int main(){
string s;
cin>>s;
int n = s.size();
bool check = true;
int cnt = 0;
for(int i = 0,j=0; i < n; i++){
if(s[i]>='0' && s[i] <= '9'){
a[cnt][j] = s[i];
j++;
}
else if(s[i] == '.'){
cnt++;
j = 0;
}
else{
check = false;
break;
}
if((cnt == 4) || (s[i] == '.' && s[i+1] == '.')){
check = false;
break;
}
}
if(cnt <3){
check = false;
}
if(check){//若ip地址是合法的
for(int i = 0; i <= cnt; i++){
int sum =0,t=1;
int len = strlen(a[i]);
for(int j = len-1; j>=0; j--){
sum += (a[i][j] - '0...
登录后发布评论
暂无评论,来抢沙发