第1个回答 2013-11-05
#include<stdio.h>
main(){
float x,y;
scanf("%f",&x);
if(x>=0)y=2*x+1;
else y=2*x-1;
printf("%.2f",y);
}
/*通过vc++6.0编译*/
第2个回答 2013-11-05
VB解答
Private Sub Command1_Click()
Dim x, y As Single
x = Text1.Text
If x >= 0 Then
y = 2 * x + 1
Else
y = 2 * x - 1
End If
Print "y="; y
End Sub
第3个回答 2013-11-05
double valueOfY(double x){
if(x>=0){
return x*2+1;
}else if(x<0){
return x*2-1;
}
}