本题目要求计算下列分段函数f(x)的值:
输入在一行中给出实数x。
在一行中按“f(x) = result”的格式输出,其中x与result都保留一位小数。
10
f(10.0) = 0.1
0
f(0.0) = 0.0
#include <stdio.h>
#include <stdlib.h>
int main()
{
double x,y;
scanf("%lf",&x);
if (x!=0)
{
y=1/x;
}
else
{
y=0;
}
printf("f(%.1lf) = %.1lf",x,y);
return 0;
}
原文:https://www.cnblogs.com/hjn123hjn/p/9880287.html