1 Packagealgorithms.fundamentals001;2 3 ImportJava.util.Locale;4 ImportJava.util.Scanner;5 6 Importalgorithms.util.StdIn;7 8 Public classIsequals {9 Ten //assume Unicode UTF-8 encoding One Private Static FinalString charset_name = "UTF-8"; A - //Assume language = 中文版, country = US for consistency with System.out. - Private Static FinalLocale locale =locale.us; the - Private StaticScanner Scanner; - //Do the once when StdIn is initialized - Static { + Resync (); - } + /** A * If StdIn changes, use this to reinitialize the scanner. at */ - Private Static voidResync () { -Setscanner (NewScanner (NewJava.io.BufferedInputStream (system.in), charset_name)); - } - - Private Static voidSetscanner (Scanner Scanner) { inIsequals.scanner =scanner; - IsEquals.scanner.useLocale (LOCALE); to } + - Public Static voidMain (string[] args) { the //int a = Scanner.nextint (); * //int b = Scanner.nextint (); $ //int c = Scanner.nextint ();Panax Notoginseng //System.out.println (a==b && b==c); - DoubleA =scanner.nextdouble (); the Doubleb =scanner.nextdouble (); +System.out.println (A > 0.0 && a < 1.0) && (b > 0.0 && B < 1.0)); A } the}
Algorithm Sedgewick Fourth Edition-1th Chapter Basics-Usage of 191 scanner