fork download
  1. import javax.swing.JFrame;
  2.  
  3. import java.io.FileNotFoundException;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import java.util.Random;
  7.  
  8. public class Test extends JFrame{
  9. public static void Parking_test() throws FileNotFoundException{
  10. for(int k = 1; k<=10; k++){
  11. double x = 0, y = 0, n = 0, m = 0;
  12. int c = 0, spr = 0, proba = 0, kolizja = 0, zaparkowany = 0;
  13. List<Double> lista_x = new ArrayList<Double>();
  14. List<Double> lista_y = new ArrayList<Double>();
  15. Random generator = new Random();
  16. for(int i = 0; i<12000; i++){
  17. x = generator.nextDouble() * 100;
  18. y = generator.nextDouble() * 100;
  19. spr = 0;
  20.  
  21. if(lista_x.isEmpty() && lista_y.isEmpty()){
  22. lista_x.add(x);
  23. lista_y.add(y);
  24. proba += 1;
  25. zaparkowany += 1;
  26. }else{
  27. for(c = 0; c <= lista_x.size(); c++){
  28. n = lista_x.get(c);
  29. m = lista_y.get(c);
  30. if(Math.max(Math.abs(x - n), Math.abs(y - m)) >= 1){
  31. spr += 1;
  32. }else{
  33. proba += 1;
  34. kolizja += 1;
  35. break;
  36. }
  37. if(spr == lista_x.size()){
  38. lista_x.add(x);
  39. lista_y.add(y);
  40. proba += 1;
  41. zaparkowany += 1;
  42. break;
  43. }
  44. }
  45. }
  46. }
  47. System.out.println(zaparkowany);
  48. }
  49. }
  50.  
  51. public static void main(String[] args) throws FileNotFoundException{
  52. for(int i = 0; i < 10; i++){
  53. Parking_test();
  54. System.out.println("--------");
  55. }
  56. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:56: error: reached end of file while parsing
		}
		 ^
1 error
stdout
Standard output is empty