2 luanpaixie262 luanpaixie262 于 2016.03.07 20:02 提问

请问这个代码应该如何写,完全没有思路啊,求解

这个怎么写代码啊,一点思路都没有,怎么办啊,求解⋯⋯⋯⋯⋯⋯⋯⋯图片说明

2个回答

luochoudan
luochoudan   Ds   Rxr 2016.03.07 21:45
已采纳

借鉴一下,改改。
public static void main(String[] args) {
// TODO Auto-generated method stub
Runtime runtime = Runtime.getRuntime();
System.out.println("占用内存:"
+ (runtime.totalMemory() - runtime.freeMemory()));
long timeStamp = System.currentTimeMillis();
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextInt()) {
int tem = scanner.nextInt();
System.out.println("输入的华氏温度是:" + tem);
Integer temperature = (tem - 32) * 5 / 9;
System.out.println("输出的摄氏温度是:" + temperature);
System.out.println("消耗时间(包含输入):"
+ (System.currentTimeMillis() - timeStamp) + "毫秒");
}
scanner.close();
}

Hello_____Word
Hello_____Word   2016.03.07 21:20

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Test {
private static int F;
public static void main(String[] args) {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
        F = Integer.parseInt(br.readLine());
    } catch (NumberFormatException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if(br != null) {
            try {
                br.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }   
    System.out.println((int)((F-32)*5/9));
}

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!