三:编程,输入x后,根据下式计算并输出y值。

#include<stdio.h>
#include<math.h>
void main ()
{
    double x,y;
    printf("输入x:");
    scanf("%lf",&x);
    if(x<-2){
        y=x*x;
    }
    else if(x>2){
        y=sqrt(x*x+x+1);
    }
    if((x>=-2)&&(x<=2)){
        y=2+x;
    }
    printf("y=f(%f)=%.2f\n",x,y);
}

 

posted @ 2013-10-31 09:46  吕鼎鼎19950427  阅读(545)  评论(1编辑  收藏  举报