第三题 输入x后,根据下式计算并输出y值。

#include<stdio.h>
#include<math.h> 
int main(void)
{
    double x,y;
    printf("enter x:");
    scanf("%lf",&x);

    if(x<-2)
        y=x*x;
    if(x>2)
        y=sqrt(x*x+x+1);
    else
        y=x+2;
    printf("%lf",y);
    return 0;
}

 

posted on 2013-10-31 09:43  chcb111  阅读(588)  评论(1编辑  收藏  举报

导航