| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么这个程序总是runtimeError,谢谢各位先大概说明一下情况,我的程序写的这么麻烦的原因是为了在本地测试方便,我加入了日志和动态代理(不过下面的代码中没有动态代理,),这样虽然看上去代码很多,实际上由于有了框架,每次做新题目其实不费事。现在的问题是这个代码在web上可以编译成功但是总是运行错误,实际上直接看main函数可以看到我的main函数其实就是faq上题目1000的标准答案(原本我的代码不是这样的,为了定位错误我不断的简化我的main,直到现在这个样子,),但是为什么还是不行呢,郁闷中。。。
btw当然我其实可以在本地通过后修改代码让它在web上也通过了,不过这样很麻烦,最好有朋友给我解释解释我的问题。感谢。
Source
Problem Id:1000 User Id:pwh06
Memory:4K Time:140MS
Language:Java Result:Runtime Error
Source
import java.io.*;
import java.util.*;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
private boolean isDebug = false;
private int a;
private int b;
private float step;
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#completConsoleInput()
*/
public void completConsoleInput() throws IOException {
initPointsVersionB();
if (isDebug()) {
// initCalculateStep();
}
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#initPointsVersionB()
*/
public void initPointsVersionB() {
logger
.info("please input 2 integers, the format must be like \"36 89\":");
BufferedReader bufin = new BufferedReader(new InputStreamReader(
System.in));
try {
String in = bufin.readLine();
Pattern p = Pattern.compile("\\d+");
Matcher m = p.matcher(in);
if (m.find())
setA( Integer.parseInt(m.group()) );
if (m.find())
setB( Integer.parseInt(m.group()) );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.info("you input 2 integer");
logger.info("first integer is" + a);
logger.info("second integer is" + b);
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#initCalculateStep()
*/
public void initCalculateStep() {
logger
.info("please input the calculating step as a float number like 0.01");
BufferedReader bufin = new BufferedReader(new InputStreamReader(
System.in));
try {
String in = bufin.readLine();
setStep( Float.parseFloat(in) );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.info("you input the step is :" + step);
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
Main proxy = new Main();
BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
String line = stdin.readLine();
StringTokenizer st = new StringTokenizer(line);
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
System.out.println(a + b);
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#getA()
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#getA()
*/
public int getA() {
return a;
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#setA(int)
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#setA(int)
*/
public void setA(int a) {
this.a = a;
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#getB()
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#getB()
*/
public int getB() {
return b;
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#setB(int)
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#setB(int)
*/
public void setB(int b) {
this.b = b;
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#isDebug()
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#isDebug()
*/
public boolean isDebug() {
return isDebug;
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#setDebug(boolean)
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#setDebug(boolean)
*/
public void setDebug(boolean isDebug) {
this.isDebug = isDebug;
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#getStep()
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#getStep()
*/
public float getStep() {
return step;
}
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000#setStep(float)
*/
/* (non-Javadoc)
* @see POJMonthly20070428.IAaddB1000a#setStep(float)
*/
public void setStep(float step) {
this.step = step;
}
Logger logger = Logger.getLogger("InfoLogging");
public Logger getLogger() {
return logger;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator