fork download
  1. public class RandomWalker1 {
  2. public static void main(String[] args) {
  3. int r = Integer.parseInt(args[0]);
  4. int steps = 0;
  5. int x = 0;
  6. int y = 0;
  7.  
  8. System.out.println("(" + x + ", " + y + ")");
  9.  
  10. while ((Math.abs(x) + Math.abs(y)) < r) {
  11. if (Math.random() > 0.75) {
  12. steps++;
  13. x++;
  14. System.out.println("(" + x + ", " + y + ")");
  15. System.out.println("1 val");
  16. continue;
  17. }
  18. if (Math.random() <= 0.75 && Math.random() > 0.50) {
  19. steps++;
  20. x--;
  21. System.out.println("(" + x + ", " + y + ")");
  22. System.out.println("75 val");
  23. continue;
  24. }
  25. if (Math.random() <= 0.50 && Math.random() > 0.25) {
  26. steps++;
  27. y++;
  28. System.out.println("(" + x + ", " + y + ")");
  29. System.out.println("50 val");
  30. continue;
  31. }
  32. if (Math.random() <= 0.25) {
  33. steps++;
  34. y--;
  35. System.out.println("(" + x + ", " + y + ")");
  36. System.out.println("25 val");
  37. }
  38. }
  39. System.out.println("steps = " + steps);
  40.  
  41. }
  42. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class RandomWalker1 is public, should be declared in a file named RandomWalker1.java
public class RandomWalker1 {
       ^
1 error
stdout
Standard output is empty