作者whiteshirts (MJIB)
看板Examination
标题Re: [考题] 100年地特四等程式语言
时间Mon Apr 1 14:52:09 2013
※ 引述《elone (吃大便打线 ...)》之铭言:
谢谢您的热心
但我发现version 1还是编译错误 结果如下所述
原因应该就是我编译器太老旧啦(Turbo C 1987, 1988) ^^
我只是单纯找个免安装编译器 主要让我练习打打程式
: 刚回到家 帮你 重新调整一下
: // version 1 如果 salary 用的是 int 那麽你 * 0.05 就不会有小数
: #include <cstdlib>
: #include <cstdio>
: int main()
: {
: int salary;
: printf("Please input your salary:");
: scanf("%d",&salary);
: if(salary>=40000)
: {
: salary *= 0.05;
: printf("Your tax is %d.",salary);
: }
: else
: {
: printf("Your tax is 0.");
: }
: return 0;
: }
=>Unable to open include file "CSTDLIB"
=>Unable to open include file "CSTDIO"
=>Constant out of range in comparison in function main/*if(salary>=40000)那行*/
改成<stdio.h>後,结果和原来一样
: //version 2
: #include <cstdlib>
: #include <cstdio>
: int main()
: {
: // 不好意思 我习惯用double @@
: double salary; //如果用float
: printf("Please input your salary:");
: scanf("%lf",&salary); //这边要改成 %f
: if( salary >=40000)
: {
: salary *= 0.05;
: printf("Your tax is %f.",salary);
: }
: else
: {
: printf("Your tax is 0.");
: }
: return 0;
: }
=>改成<stdio.h>,确实可以正常执行,和float & %f结果一样
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.32.73.12