├── .classpath ├── .gitignore ├── .project └── src └── application └── Program.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | # Eclipse 26 | .settings/ 27 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | course 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/application/Program.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Program { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner sc = new Scanner(System.in); 10 | 11 | int m = sc.nextInt(); 12 | int n = sc.nextInt(); 13 | int[][] mat = new int[m][n]; 14 | 15 | for (int i=0; i 0) { 28 | System.out.println("Left: " + mat[i][j-1]); 29 | } 30 | if (i > 0) { 31 | System.out.println("Up: " + mat[i-1][j]); 32 | } 33 | if (j < mat[i].length-1) { 34 | System.out.println("Right: " + mat[i][j+1]); 35 | } 36 | if (i < mat.length-1) { 37 | System.out.println("Down: " + mat[i+1][j]); 38 | } 39 | } 40 | } 41 | } 42 | 43 | sc.close(); 44 | } 45 | } 46 | --------------------------------------------------------------------------------