编程题输入x,计算并输出下列分段函数y的值!

如题所述

#include <stdio.h>
#include <math.h>

int main()
{
    double x,y;
    printf("Input x:");
    scanf("%lf",&x);
    if(x<=1){
        y=pow(2.718281828,x);
    }else{
        y=x*x-1;
    }
    printf("y=%lf\n",y);
    return 0;
}

追问

谢谢🙏

温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-10-27
#include<stdio.h>
#include<math.h>
void main() { double x,y;
scanf("%lf",&x);
if ( x<=1 ) y=exp(x);
else y=x*x-1;
printf("%lf\n",y);
}
相似回答