D.6三角公式求值

xiaoxiao2021-02-28  124

任务及代码

/* *copyright(c)2017,学院 *All rights reserved. *文件名称: main.c *作 者: 杨隆胜 *完成日期: 2017年8月6日 *版 本 号: v1.0 * *问题描述:写一程序,求y值 (x值由键盘输入)。y=(sin(x)+cos(x))/2 (x>=0);y=(sin(x)-cos(x))/2 (x<0). *输入描述:输入x; *程序输出:输出y; */ #include <stdio.h> #include <math.h> int main() { double x,y; printf("Please input the value of x:\n"); scanf("%lf",&x); if(x>=0) { y=(sin(x)+cos(x))/2; } else { y=(sin(x)-cos(x))/2; } printf("The corresponding value of function is:%lf",y); return 0; } 运行结果

知识点总结

在调用诸如三角函数、开根号等函数时需要在头文件加入include<math.h>方可成功调用该函数。

心得体会

人工智能从今年年初就非常火热,那么我到底能不能抓住这次机会呢,我什么时候才可以进入到这个层次呢?

转载请注明原文地址: https://www.6miu.com/read-45198.html

最新回复(0)