实验7(3)

#include<stdio.h>
#include<math.h>
int main(void)
{
    double x,y;
    /*定义两个双精度浮点型变量*/

    printf("Enter x:");
    scanf("%Lf",&x);
    if(x<-2){
        /*求当x<-2时的值*/
        y=x*x;
    }
    else if(x>2){
        y=sqrt(x*x+x+1);
    }
    else{
        y=2+x;
    }
    printf("f(%.2f)=%.2f
",x,y);
    /*调用printf()函数输出结果*/
    return 0;
}
原文地址:https://www.cnblogs.com/lxhlxx900126/p/3398534.html