Java 输入一组数字,用穷举的方法列出

import java.util.Scanner;

public class TestScanner {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Password: ");
        long password = scanner.nextLong();
        
        long pwd = 0;
        long t1 = System.currentTimeMillis();
        while (pwd != password) {
            ++pwd;
        }
        long t2 = System.currentTimeMillis();
        System.out.printf("The password you entered is %s\n", password);
        System.out.printf("elapsed time: %s ms", (t2 - t1));
        scanner.close();
    }
}

 

posted @ 2018-10-16 12:02  heismk  阅读(846)  评论(0编辑  收藏  举报