Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.89 KB | None | 0 0
  1. //package javaapplication1;
  2.  
  3. import java.util.*;
  4. import java.*;
  5. import java.io.FileReader;
  6. import java.io.FileWriter;
  7. import java.io.PrintWriter;
  8. import java.io.File;
  9. import java.lang.String;
  10. import java.util.regex.*;
  11.  
  12. public class Main {
  13.    
  14.    public static void main(String[] args) throws Exception{
  15.        
  16.        Scanner in = new Scanner(new FileReader("input.txt"));
  17.         PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
  18.         String s = in.nextLine();
  19.         //[0-9]{1,2}|1[0-9]{2}|25[0-6]{1}|2[0-4]{1}[0-9]{1}[\\u002E]{1}
  20.         String mask = "[0]{0,170}([0-9]{1,2}|1[0-9]{2}|25[0-5]{1}|2[0-4]{1}[0-9]{1})";
  21.        Pattern p = Pattern.compile(mask + "[\\u002E]{1}" + mask + "[\\u002E]{1}" + mask + "[\\u002E]{1}" + mask );
  22.        Matcher tmp = p.matcher(s);
  23.        
  24.        if(!tmp.matches() )
  25.            System.out.println(0);
  26.       else
  27.            System.out.println(1);
  28.  
  29.    }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement