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(); } }