输出的结果不对,求助各位大神!
本帖最后由 panzhengwang 于 2022-6-29 20:18 编辑#include <stdio.h>
#include <math.h>
void main()
{
double x, s;
printf("input number:\n");
scanf("%if", &x);
s = sin(x);
printf("sin of %if is %if\n", x, s);
}
输入
30
sin of 30f is-85993460f
与老师的结果完全不一样!!
谢谢啦
刚才检查了一下发现 lf 写成if了
#include <stdio.h>
#include <math.h>
void main()
{
double x, s;
printf("input number:\n");
scanf("%lf", &x);
s = sin(x);
printf("sin of %lf is %lf\n", x, s);
}
现在的结果是-0.988032 答案没有问题啊,你的 x 是弧度还是角度? printf("sin of %if is %if\n", x, s);
%if 吗?
是 %lf
认真一点呀,学编程就是要一点也不能马虎,因为稍微一不注意就出问题了
就像你现在这样
http://c.biancheng.net/ref/sin.html sin 的参数是 弧度
人造人 发表于 2022-6-29 20:33
http://c.biancheng.net/ref/sin.html
大神
页:
[1]