double f(double x)
{
double result;
if(x<0)
result=-x+sin(x);
else if(x==0)
result=0;
else if(10>x>0)
result=log2(x);
else if(x>=10)
result=pow(x,2);
return result;
}
double f(double x)
{
double result;
if(x<0)
result=-x+sin(x);
else if(0<x<10)
result=log2(x);
else if(x==0)
result=0;
else if(x>=10)
result=pow(x,2);
return result;
}
对于上述两种写法,第一种是正确的,因为那些数大小的顺序有逻辑性(现阶段的理解)
原文地址:https://www.cnblogs.com/advsd/p/11778481.html
时间: 2024-10-13 20:54:24