一枚枕头 发表于 2020-1-27 21:53:11

Hello world相关例题 我的代码编译出来与小甲鱼的不同 .

本帖最后由 一枚枕头 于 2020-1-27 21:53 编辑

Hello world相关例题 我的代码编译出来与小甲鱼的不同 小甲鱼的可以计算sin30的确定的数值,而我的计算结果是sin30f请问是哪里出错了呢{:5_92:}

#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);
}

zltzlt 发表于 2020-1-27 21:59:41

是 %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);
}

一枚枕头 发表于 2020-1-27 22:29:08

zltzlt 发表于 2020-1-27 21:59
是 %lf 不是 %If

正确代码:

我改正了代码后还是输出sin30f{:5_105:}

chxchxkkk 发表于 2020-1-28 16:06:29

2楼是正解,你代码书写的肯定有问题。
input number:
30
sin of 30.000000 is -0.988032

一枚枕头 发表于 2020-2-14 19:36:11

chxchxkkk 发表于 2020-1-28 16:06
2楼是正解,你代码书写的肯定有问题。
input number:
30


好的 谢谢你呀
页: [1]
查看完整版本: Hello world相关例题 我的代码编译出来与小甲鱼的不同 .