void main()
{
int x,int y;
printf("请输入X的值:");
scanf("%d",&x);
printf("\n");
if(x<0)
{
y=-2*x+10;
}
else
{
y=3*x+20;
}
printf("Y的值为:%d",&y);
}
#include
double fun(double x){
double y;
if(x<0) y=2*x+10;
else y=3*x+20;
return y;
}
int main(){
double x;
printf("Enter the value of x: ");
scanf("%f",x);
printf("The value of y is %f.\n",fun(x));
return 0;
}
#include
using namespace std;
int main()
{
float x,y;
cout<<"input x please:"<
if(x<0)
y=-2*x+10;
else
y=3x+20;
cout<<"y= "<
}
program func;
var x:extended;
begin
readln(x);
if x<0 then writeln(-2*x+10)
else writeln(3*x+20);
end.