我用Xcode作为编译器学习C语言,代码如下:
#include <stdio.h>
int main(void)
{
float weight;
float value;
printf("are you worth your weight in rhodium?\n");
printf("let's check it out.\n");
printf("please enter your weight in pounds: ");
scanf("%f", &weight);
value = 770 * weight * 14.5833;
printf("your weight in rhodium is worth $%.2f.\n", value);
printf("you are easily worth that! If rhodium prices drop,\n");
printf("eat more to maintain your value.\n");
return 0;
}
按理说代码应该没有问题,但是我编译后输出结果却是这样:
are you worth your weight in rhodium?
let's check it out.
please enter your weight in pounds: 150
your weight in rhodium is worth $310815099620643345268736.00.
you are easily worth that! If rhodium prices drop,
eat more to maintain your value.
另外,我发现Xcode中有以下内容:
我用其他编译器显示的是正确的结果。请问为什么Xcode中会变成这样奇怪的数字,应该如何设置或修改?
菜鸟拜谢大神~~~!!!
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。