作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不知道如何使用顶级编码器的离线可视化工具。这是我第一次尝试进行 topcoder 挑战。割草机挑战: https://community.topcoder.com/longcontest/?module=ViewProblemStatement&rd=16612&pm=14078
这是我在主类中使用的与可视化工具一起使用的内容:
public class Main {
public static void main(String[] args) {
LawnMowing lawnMowing = new LawnMowing();
int N;
int turnCost;
int forwardCost;
int slopeCost;
int startCol;
int startRow;
//System.out.println("Lawn Mower Begin:");
Scanner sc = new Scanner(System.in);
N = Integer.parseInt(sc.nextLine());
String[] yard = new String[N];
for (int i=0; i < N; i++){
yard[i] = (String) sc.nextLine();
}
turnCost = Integer.parseInt(sc.nextLine());
forwardCost = Integer.parseInt(sc.nextLine());
slopeCost = Integer.parseInt(sc.nextLine());
startCol = Integer.parseInt(sc.nextLine());
startRow = Integer.parseInt(sc.nextLine());
System.out.println();
String ret = lawnMowing.getMoves(yard, turnCost, forwardCost, slopeCost, startCol, startRow);
System.out.print(ret);
System.out.flush();
}
这是我为 getMoves() 函数设置的基本类
import java.util.Scanner;
public class LawnMowing {
public String getMoves(String[] yard, int turnCost, int forwardCost, int slopeCost, int startCol, int startRow){
String leftTurn = "L";
String rightTurn = "R";
String straight = "S";
String moves = "";
for(int i=0 ; i < 10; i++){
moves += leftTurn;
moves += straight;
moves += rightTurn;
moves += straight;
}
return moves;
}
}
这是我的终端命令:
Charless-MacBook-Pro:Documents Charles$ cd workspace
Charless-MacBook-Pro:workspace Charles$ ls
Graphics2 RemoteSystemsTempFiles
LawnMowing tester.jar
Charless-MacBook-Pro:workspace Charles$ cd LawnMowing
Charless-MacBook-Pro:LawnMowing Charles$ ls
bin src
Charless-MacBook-Pro:LawnMowing Charles$ cd src
Charless-MacBook-Pro:src Charles$ ls
LawnMowing.class LawnMowingVis.java Main.java
LawnMowing.java Main.class tester.jar
Charless-MacBook-Pro:src Charles$ java -jar tester.jar -exec "java -cp Main"
这是我的终端输出:
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
ERROR: Unexpected error while running your test case.
java.lang.NullPointerException
at LawnMowingVis.runTest(LawnMowingVis.java:438)
at LawnMowingVis.main(LawnMowingVis.java:524)
请让我知道我做错了什么!
最佳答案
命令应该是:
java -jar tester.jar -exec "java -cp . Main"
有一个“。”在-cp
之后。 -cp
开关指定类路径,即当前目录(单个句点字符表示当前目录)。
关于java - TopCoder 使用离线可视化工具进行割草挑战,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35980672/
我是一名优秀的程序员,十分优秀!