fork download
  1. public class Main{
  2. public static char[][] minesweeper(char[][] woclues){
  3. for(int i = 0; i < woclues.length ; i++){
  4. for(int j = 0; j < woclues[0].length ; j++){
  5. if( woclues[i][j] == ' '){
  6. woclues[i][j] = '0';
  7. for(int x = i - 1; x < i + 1 ; x++){
  8. for(int y = j - 1; y < j + 1 ; y++){
  9. try{
  10. if(woclues[x][y] == '*'){
  11. woclues[i][j]++;
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }
  18. return woclues;
  19. }
  20. public static void main(String[]args){
  21. char[][] in = new char[args.length][args[0].length()];
  22. for(int i = 0; i < args.length;i++){
  23. in[i]=args[i].toCharArray();
  24. }
  25. for(char[] c:minesweeper(in)){
  26. System.out.println(new String(c));
  27. }
  28. }
  29. }
Runtime error #stdin #stdout #stderr 0.04s 711168KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
	at Main.main(Main.java:22)