已知函数y=f(x),编程实现输入一个x值,输出y值。2x+1(x<0)y=0(x=0)2x-1(x>0)
举一反三
- 已知函数x + 3 ( x >; 0 )y = 0( x = 0 )x*x –1 ( x <; 0 )请从键盘输入x值,再在控制台输出对应的y值。
- 【单选题】分段函数: ,下面程序段中正确的是__________。 A. If x < 0 Then y = 0 If x < 1 Then y = 1 If x < 2 Then y = 2 If x >= 2 Then y = 3 B. If x >= 2 Then y = 3 If x >= 1 Then y = 2 If x > 0 Then y = 1 If x < 0 Then y = 0 C. If x < 0 Then y = 0 ElseIf x > 0 Then y = 1 ElseIf x > 1 Then y = 2 Else y = 3 End If D. If x > =2 Then y = 3 ElseIf x > =1 Then y = 2 ElseIf x > =0 Then y = 1 Else y = 0 End If
- 有一个分段函数,当x大于0时,y的值是1;当x为0时,y的值是0;当x A: if(x >= 0)if(x > 0) y = 1;else y = 0;else y = -1; B: if(x > 0) y = 1;else if(x == 0) y = 0;else y = -1; C: y = 0;if(x > 0) y = 1;else if(x D: y = 0; if(x >= 0); if(x > 0) y = 1; else y = -1;
- 有一函数,其功能为:若x<0,y的值为-1;若x=0,y的值为1;以下程序段中不能根据x值正确计算出y值的是 A: if(x>=0)if(x>0)y=1; else y=0;else y=-1; B: if(x>0)y=1; else if(x==0)y=0;else y=-1; C: y=0;if(x>=0) if(x>0) y=1;else y=-1; D: y=0;if(x>0) y=1;else if(x<0) y=-1
- 分段函数:[img=206x91]18037123bea18f3.png[/img],下面程序段中正确的是__________。 A: If x < 0 Then y = 0If x < 1 Then y = 1If x < 2 Then y = 2If x >= 2 Then y = 3 B: If x > =2 Then y = 3ElseIf x > =1 Then y = 2ElseIf x > =0 Then y = 1Else y = 0End If C: If x >= 2 Then y = 3If x >= 1 Then y = 2If x > 0 Then y = 1If x < 0 Then y = 0 D: If x < 0 Then y = 0ElseIf x > 0 Then y = 1ElseIf x > 1 Then y = 2Else y = 3End If E: If x < 0 Then y = 0If 0 <= x <1 Then y = 1If 1 <= x < 2 Then y = 2If x >= 2 Then y = 3