Advertisement
cd62131

Match Integer

Feb 2nd, 2014
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MatchInteger {
  4.   public static void main(String[] args) {
  5.     int[] password = {22, 33, 44};
  6.     Scanner in = new Scanner(System.in);
  7.     boolean match = true;
  8.     for (int p: password) {
  9.       try {
  10.         if (p != new Integer(in.nextInt())) match = false;
  11.       }
  12.       catch (Exception e) {
  13.         match = false;
  14.         break;
  15.       }
  16.     }
  17.     in.close();
  18.     if (match) System.out.println("一致");
  19.     else System.out.println("不一致");
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement