练习三

3.已知函数,输入x的值,输出对应的y的值. x + 3 ( x > 0 ) y = 0 ( x = 0 ) x2 –1 ( x < 0 )
package
apple; import java.util.*; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int x=input.nextInt(); int y; if(x>0) { y=x+3; } else { if (x<0) { y=(2*x)-1; } else y=0; } System.out.println(y); }
}

 


 


3.已知函数,输入x的值,输出对应的y的值. x + 3 ( x > 0 ) y = 0 ( x = 0 ) x2 –1 ( x < 0 )

posted @ 2020-03-21 09:59  青衫故人1118  阅读(93)  评论(0编辑  收藏  举报