如果你是说CS1102 lab 0的话
所在版块:社会百科 发贴时间:2003-01-21 00:46  评分:

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
import java.io.*;
import java.util.*;
import java.text.NumberFormat;

class Q4 {
//main class
public static void main(String []args) throws Exception{

BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String thisLine;
StringTokenizer st;

double a, b;
boolean blank = false;
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
nf.setMinimumFractionDigits(2);
while((thisLine=stdin.readLine())!=null){
st = new StringTokenizer(thisLine);
a = Double.parseDouble(st.nextToken());
b = Double.parseDouble(st.nextToken());
if (blank)
System.out.print(" ");
else
blank = true;
System.out.print(nf.format(a/b));
}
System.out.println();
}
}
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

我爬~~~~~
 相关帖子 我要回复↙ ↗回到正文
java里面怎么format number? 辰星   (110 bytes , 648reads )
Quite lots of ways..^^^ maserati   (321 bytes , 360reads )
[SUGGESTION]THIS IS WRONG! 不告诉你   (61 bytes , 218reads )
如果你是说CS1102 lab 0的话 Climbing   (743 bytes , 292reads )
hey!!! 你怎么干这种事? 采心   (55 bytes , 246reads )
lab 0 lah Climbing   (8 bytes , 190reads )
.......是不应该给答案,但也不应该这样地骂。。。 coolapple   (0 bytes , 173reads )
:$ 采心   (85 bytes , 206reads )
haha... 不告诉你   (0 bytes , 186reads )
here SmellsLikeTeenSpirit   (177 bytes , 204reads )