fork download
  1. // как считать четные числа с файла на 10000 цифр? и остановит подсчет при встрече нуля
  2.  
  3.  
  4. import java.util.*;
  5. import java.io.*;
  6.  
  7.  
  8. class Main{
  9. public static void main(String[] args) throws FileNotFoundException {
  10.  
  11. File file = new File("C:\\Users\\Zhake\\Desktop\\dataset_91065.txt");
  12. Scanner scan = new Scanner(file);
  13. int[] nums = new int[10000];
  14.  
  15. int plus = 0;
  16. for(int i = 0; i < 10000; i++) {
  17. nums[i] = scan.nextInt();
  18. //System.out.println(nums[i] +" - " + i);
  19.  
  20. if((nums[i] % 2 == 0) && (nums[i] != 0)) {
  21. plus++;
  22. }
  23. }
  24. System.out.println(plus);
  25.  
  26. scan.close();
  27. }
  28. }
  29. // это файл на 10000 integer, https://y...content-available-to-author-only...i.sk/d/U3ScIMsV0wyuOg
Runtime error #stdin #stdout #stderr 0.08s 34024KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.io.FileNotFoundException: C:\Users\Zhake\Desktop\dataset_91065.txt (No such file or directory)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
	at java.base/java.util.Scanner.<init>(Scanner.java:639)
	at Main.main(Main.java:12)