解题思路:
注意事项:
参考代码:
import java.util.Iterator;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
while (input.hasNext())
{
String str = input.nextLine();
String[] word = str.split("\\.");
if (CheckEle.check(word))
{
System.out.println("Y");
} else
{
System.out.println("N");
}
}
}
}
class CheckEle
{
public static boolean check(String[] word)
{
for (String string : word)
{
if (!check(string))
{
return false;
}
}
return true;
}
public static boolean check(String s)
{
int n = 0;
try
{
n = Integer.valueOf(s);
} catch (Exception e)
{
return false;
}
return n <= 255 && n >= 0;
}
}
0.0分
0 人评分