数组的应用
public class ifDemo2 {
public static void main(String[] args) {
System.out.println(“开始”);
//x和y的关系满足如下
//x>=3 y = 2x + 1
//-1<=x<3 y = 2x
//x <=-1 y = 2x - 1
//根据给定的x的值,计算出y的值并输出。
//定义变量
int x = 5;
//给x从新赋值
x = 6;
int y;
if(x > 3) {
y = 2*x + 1;
}else if(x>=-1 && x<3) {
y = 2*x;
}else if(x<=-1) {
y = 2* - 1;
}else {
y = 0;
System.out.println("不存在这样的x");
}
System.out.println("y:"+y);
System.out.println("结束");
}
}

480

被折叠的 条评论
为什么被折叠?



