用C语言表达
y=1/x x<1
y=2x-1 1≤x<5
y=√x²-9 5≤x
写一程序,输入x的值输出y的值
#include <stdio.h>
#include <math.h>
int main()
{
double x,y;
scanf("%lf",&x);
if(x<1)
y = 1/x;
else if(x>=1 && x<5)
y = 2*x-1;
else
y = sqrt(x*x-9);
printf("%lf",y);
return 0;
}
#include "stdio.h"
#include <math.h>
void main()
{
float x,y;
scanf("%f",&x);
if(x<1)
y= 1.0/x;
else if(x>=1 && x<5)
y = 2*x-1;
else
y = sqrt(x*x-9);
printf("y=%f",y);
}