添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
悲伤的冰棍  ·  html - helvetica font ...·  1 年前    · 
importjava.lang.*;importjava.io.*;classexponent{publicstaticvoidmain(Stringargs[]){Ob... import java.lang.*;
import java.io.*;

class exponent
{
public static void main(String args[])
{
ObjectInputStream jin = new ObjectInputStream(System.in);
double tsampled = Double.Double(args[1]).doubleValue();
while(tsampled!=Double.NaN)
{
System.out.print(Double.valueOf(tsampled));
System.out.print(Math.getExponent(Double.valueOf(tsampled)));
tsampled = jin.readDouble();
}
}
};

//F:\doc\source codes\java\exponent>javac exponent.java
//exponent.java:9: 未报告的异常 java.io.IOException;必须对其进行捕捉或声明以便抛出
// ObjectInputStream jin = new ObjectInputStream(System.in);
// ^
//exponent.java:10: 未报告的异常 java.io.IOException;必须对其进行捕捉或声明以便抛出
// double tsampled = jin.readDouble();
// ^
//2 错误
//
//F:\doc\source codes\java\exponent>

顺便问一下,System.in怎么用? public static void main(String args[]) throws IOException { //你这里写错了
ObjectInputStream jin = new ObjectInputStream(System.in);
double tsampled = Double.valueOf(args[0]); //你这里方法写错了,而且貌似数组下标也用错了
while (tsampled != Double.NaN) {
System.out.print(Double.valueOf(tsampled));
System.out.print(Math.getExponent(Double.valueOf(tsampled)));
tsampled = jin.readDouble();
}
}

仅检查语法,没有做其他检查

这是根据你的需求写的代码(我理解中的你的需求):

public static void main(String args[]) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
String line = reader.readLine();

while (line != null) {

double tsampled = Double.valueOf(line);
System.out.println(tsampled);
System.out.println(Math.getExponent(tsampled));
line = reader.readLine();
}
}