📄 main.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package marstraveler;import java.io.*; import java.util.*; /** * * @author Administrator */public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Traveler []Rob=new Traveler[4]; int line=-1; int Mx=0; //高原右上角x坐标 int My=0; //高原右上角y坐标 String dir=new String(); String s=new String(); try{ BufferedReader in=new BufferedReader(new FileReader("F:/a.txt")); while((s=in.readLine())!=null) { if(line==-1) { StringTokenizer t=new StringTokenizer(s," "); Mx=Integer.parseInt(t.nextToken()); My=Integer.parseInt(t.nextToken()); line++; } else { if(line%2==0) { System.out.println("第"+(line/2+1)+"号:"); Rob[line/2]=new Traveler(Mx,My); //初始line/2号探测器 dir=Rob[line/2].siteInitial(s); line++; } else { int k=0; k=Rob[(line-1)/2].moveSet(s, dir); if(k==0) //k==0时 探测器在移动时未超出范围 { Rob[(line-1)/2].getInfor(); line++; } else{ line++; } } } } } catch(Exception e) { } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -