Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.94 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.         Scanner in = new Scanner(System.in);
  16.      //  Scanner in = new Scanner(new FileReader("input.txt"));
  17.        // PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
  18.         String s = in.nextLine();
  19.  
  20.        Pattern p = Pattern.compile("[0]{0,170}([0-9]{1,2}|1[0-9]{2}|25[0-5]{1}|2[0-4]{1}[0-9]{1})[\\.]{1}[0]{0,170}([0-9]{1,2}|1[0-9]{2}|25[0-5]{1}|2[0-4]{1}[0-9]{1})[\\.]{1}[0]{0,170}([0-9]{1,2}|1[0-9]{2}|25[0-5]{1}|2[0-4]{1}[0-9]{1})[\\.]{1}[0]{0,170}([0-9]{1,2}|1[0-9]{2}|25[0-5]{1}|2[0-4]{1}[0-9]{1})");
  21.  
  22.        if(!p.matcher(s).matches() )
  23.            System.out.println(0);
  24.        else
  25.            System.out.println(1);
  26.  
  27.    }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement