首页 > 编程知识 正文

编写程序计算分段函数

时间:2023-05-05 04:56:44 阅读:251924 作者:662

#include <stdio.h> #include <math.h>#define PI 3.1415927int main(){double x,ans,tmp1,tmp2;while(scanf("%lf",&x)!=EOF){if(x>0){tmp1 = sqrt(x)+exp(x);tmp2 = 5*x+5;ans = tmp1/tmp2;}else{ans = (2.0/3.0+sin(60*PI/180))*(-x);}printf("%fn",ans);}return 0;}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。