找了一些资料问题还是没有解决文本中的几条纪录:
-30.000   10.000
-34.000   12.000
-38.000   14.000
-42.000   16.000
-44.000   18.000
-50.000   20.000
-54.000   22.000
-58.000   24.000
我用split() 读到这些数据,需要把他们转为数值型的,来进行计算,得到第三列的值。第三列 = 第一列 - 第二列/2
输出结果应为:
-30.000   10.000  -35
-34.000   12.000  -40
-38.000   14.000  -45
-42.000   16.000  -50
-44.000   18.000  -53
-50.000   20.000  -60
-54.000   22.000  -65
-58.000   24.000  -70

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【cookies1st】截止到2008-07-24 20:16:38的历史汇总数据(不包括此帖):
    发帖的总数量:1                        发帖的总分数:0                        每贴平均分数:0                        
    回帖的总数量:3                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:1                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:---------------------
    无满意结贴率:0.00  %               无满意结分率:---------------------
    敬礼!
      

  2.   

    如果是从文件中读就:
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("E:/*.txt")));
    String line = br.readLine();
    while (line != null) {
    System.out.println("俩数的差为:" + Integer.parseInt(line.split(" ")[0]) -  Integer.parseInt(line.split(" ")[1]));
    }
    这样就应该能得到。
    直接写的。
    看思路。
      

  3.   

    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("E:/*.txt")));
    String line = "";
    while ((line=br.readLine()) != null) {
    System.out.println("俩数的差为:" + Integer.parseInt(line.split(" ")[0]) -  Integer.parseInt(line.split(" ")[1]));
    }
      

  4.   

    先转成float,再转int
     float first_value = Float..parseFloat(str_list[1]);