public class Robot
{
public static void main(String []args){
ArrayList<String> list = new ArrayList<String>();
String path = "";
int N = 2;
int ol1_right = 1;
int ol1_down = 1;
int ol2_right = 1;
int ol2_down = 1;
buildPath (right, down, path, allPaths, N);
System.out.println (allPath(grid));
}
public void BuildPath (int right, int down, String path,
ArrayList<String> allPaths, int N){
path += "(" + down "," + right + ")->";
if (right == N-1 && down == N-1){
allPaths.add(path);
return;
}
else if (right +1 == ol1_right && down == ol1_down) && (right +1 ==
ol2_right && down == ol2_down);{
return;
}
if (right +1 == ol1_right && down == N-1) || (right +1 == ol2_right
&& down == N-1);{
return;
}
if (right == N-1 && down +1 == ol1_down) || (right == N-1 && down +1
== ol2_right);{
return;
}
if (right == N-1 || right +1 == ol1_right && down == N-1 ||
right +1 == ol2_right && down == N-1){
BuildPath (right, down + 1, path, allPaths, N);
}
else if (down == N-1 || right +1 == ol1_right && down == ol1_down && right +1 ==
ol2_right && down == ol2_down){
BuildPath (right + 1, down, path, allPaths, N);
}
else
BuildPath (right + 1, down, path, allPaths, N);
BuildPath (right, down + 1, path, allPaths, N);
}
}
对不起,即时通讯仍然是新的这种事情,我坚持试图让这个程序工作,但有点卡在哪里去下。我遇到如“非法表达式开始”(使用||和&时抛出)或“不是语句”(路径+ =“(”+ down“即时通讯试图做的是让(机器人)沿网格移动,同时只能向下和向右移动,但也有能力将网格的某些部分标记为禁区。任何帮助将不胜感激,我知道这一切看起来很可怕,但只是试图得到这个窍门,所以对任何菜鸟错误或愚蠢的错误仍然非常新的抱歉:)Abit卡住了为什么我不能得到这个工作:/
因为ISN 't的JavaScript一开始 –
对不起发誓我打了java – Daniel
你好,欢迎来到丹尼尔StackOverflow。你应该在你的问题中包含哪一行会引发编译错误或异常,可能是完整的堆栈跟踪,并告诉我们你想实现的目标。另外,如果我是你,我会阅读关于jUnit以及如何单元测试你的代码。这将大大帮助你找出问题的出处,并导致更干净的代码作为副作用。 –