实验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\n",x,y);
    /*调用printf()函数输出结果*/
    return 0;
}

 

posted @ 2013-10-31 09:44  plusfancy  阅读(81)  评论(0编辑  收藏  举报