TA的每日心情 | 开心 2014-6-18 08:29 |
---|
签到天数: 14 天 [LV.3]偶尔看看II
滴水大师
 
- 积分
- 2345
|
题目
解决代码及点评
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- void main()
- {
-
- double x,y;
- printf("please input x"); // 提示用户输入x
- scanf_s("%lf",&x); /// 通过scanf_s让用户输入x的值
- if (x>=0) // 如果x>=0
- {
- y=(sin(x)+cos(x))/2; // 则通过函数对于x>0部分的方程进行计算
- }
- else
- {
- y=(sin(x)-cos(x))/2; // 否则通过函数x<0部分的方程进行计算
- }
- printf("%lf",y); // 输出结果
- system("pause");
- }
|
|