英语生活住房常用单词:编程:下列给定公式,根据给定的X的值,计算Y值.当X<0时,Y=X, X>=0时,Y=X^2

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/09 02:46:17

我不知道你用的是什么软件大概是这样:
Private Sub Command1_Click()
x = Text1
y = Text2
If x < 0 Then
x = y
End If
If x >= 0 Then
y = x * x
End If
声明你自己加上吧。
End Sub

你要用什么语言编?

#include<stdio.h>
int main()
{
double x,y;
printf(\"please input x\\n\");
scanf(\"%lf\",&x);
if(x<0)
y=x;
else
y=x*x;
printf(\"y=%lf\",y);
return 0;
}

if(x<0)
int y=x;
if(x>=0)
int y=x*x;
大体思想