#include<stdio.h>
#include<string.h>
int main()
{ char str[31];
int s,i,j=0;
int st[3];
while(scanf("%s",&str)!=EOF)
{ s=strlen(str);
if(str[0]!='1'&&str[0]!='2')//开头第一个不是1或2,结束
{ printf("N\n");
goto loop;
}
for(i=0;i<s;i++)
{ if((str[i]<48||str[i]>57)&&str[i]!='.')//输入中有任意一个不是点的字符,结束
{
printf("N\n");
goto loop;
}
if(str[i]=='.')
{ st[j]=i;//记下三个点在数组的位置
if(str[st[j]+1]=='0')每个点的下一位以零开头结束
{
printf("N\n");
goto loop;
}
j++;
}
}
if(st[0]>3)第一个点前的部分判断是不是在255间
{
printf("N\n");
goto loop;
}
else if(st[0]==3)
{ if((str[0]*100+str[1]*10+str[2])>255)
{
printf("N\n");
goto loop;
}
}
if(str[st[1]+1]==0||str[st[2]+1]==0)
{
printf("N\n");
goto loop;
}
if((st[1]-st[0]-1)>3)//间距大于三,说明是4位数,同上
{
printf("N\n");
goto loop;
}
else if((st[1]-st[0]-1)==3)
{if((str[st[0]+1]*100+str[st[0]+2]*10+str[st[0]+3])>255)
{
printf("N\n");
goto loop;
}
}
if((st[2]-st[1]-1)>3)同上
{
printf("N\n");
goto loop;
}
else if((st[2]-st[1]-1)==3)
{if((str[st[1]+1]*100+str[st[1]+2]*10+str[st[1]+3])>255)
{
printf("N\n");
goto loop;
}
}
printf("Y\n");
loop: i=0;//做跳转的语句
}
}
0.0分
2 人评分
弟弟的作业 (C++代码)浏览:1294 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:742 |
输出正反三角形 (C语言代码)格式错误!!!浏览:1140 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:1222 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:1090 |
【金明的预算方案】 (C++代码)浏览:837 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:581 |
Cylinder (C语言描述,蓝桥杯)浏览:1247 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:606 |
愚蠢的摄影师 (C++代码)浏览:932 |