解题思路:
注意事项: 坑爹的题目
参考代码:
#include<iostream>
#include<string>
#include<algorithm>
#include<string.h>
using namespace std;
int f(string s){
if(!isdigit(s[0]))
return 0;
int t = 0;
for(int i=0; i<s.length(); i++)
if(!isdigit(s[i]))
return 0;
else
t = t*10 + s[i]-'0';
if(t>255)
return 0;
return 1;
}
int main(){
char s[100];
while(scanf("%s",s) != EOF){
string t;
int i=0;
int n = 4;
while(n--){
for(; i<strlen(s); i++)
if(s[i] != '.')
t += s[i];
else{
i++;
break;
}
if(!f(t))
break;
t = "";
}
if(n>=0)
cout<<'N'<<endl;
else
cout<<'Y'<<endl;
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题9.2 (Java代码)浏览:611 |
兰顿蚂蚁 (C++代码)浏览:1091 |
上车人数 (C语言代码)浏览:778 |
C语言训练-阶乘和数* (C语言代码)-------- 呆板写法浏览:1351 |
C语言训练-尼科彻斯定理 (C语言代码)浏览:464 |
WU-输出正反三角形 (C++代码)浏览:1018 |
母牛的故事 (C语言代码)浏览:549 |
循环入门练习5 (C语言代码)浏览:837 |
核桃的数量 (C语言代码)浏览:871 |
时间转换 (C语言代码)浏览:627 |