编辑代码

#include <stdio.h>
#include <math.h>
int main()
{
    int x;
    printf("输入x为");
    scanf("%d", &x);
    double y;
    if (x + 2 < 0) { 
        y = - x;
    } 
    if ((x + 2 >= 0) && (x < 6)) {
        y = x * x + 3;
    }
    if (x == 6) {
        y = 4;
    } if (x > 6) {
        y = sqrt(x) ;
    }
    printf("y的值为%f",y);
    return 0;
}