编程计算下列表达式的值
编程计算下列表达式的值: (1)unsigned int 型数据:1+4294967295=?;1-4294967295=? (2)int 型数据:2147483647+1=?;-2147483648-1=? (3)float 型数据:(1.0+123456.789e30)+(-123456.789e30)=? 1.0+(123456.789e30 +(-123456.789e30))=? 要求分别用十进制和十六进制形式显示各种操作的结果
最佳答案
package baidu_question_random;
import java.io.ObjectInputStream.GetField;
import java.util.Scanner;
public class Demo_2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int y=get_value(sc.nextInt());// 获得一个输入x的值
System.out.println(y);//输出 函数执行后 y 的值
}
public static int get_value(int x){
if(x<=0){
return 2-x;
}
else if(0<x&&x<=2){
return x+2;
}
else if(2<x&&x<=5){
return x*x;
}
else if(x>5){
return 25-x;
}
else return 0;
}
}
其他回答
暂无其它回答!