标题:变量类型!
取消只看楼主
huangshengql
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2013-3-20
结帖率:71.43%
已结贴  问题点数:9 回复次数:0 
变量类型!
#include<stdio.h>
#include<stdlib.h>
int main()
{
    long int gain;
    int prize1,prize2,prize4,prize6,prize10,prize=0.0;
    printf("***********************************************\n");
    printf("*     The program will solve                  *\n");
    printf("    the problem of prize distribution         *\n");
    printf("***********************************************\n");
    printf("please input the num of gain:");
    scanf("%ld",&gain);
    prize1=100000*0.1;
    prize2=prize1+100000*0.075;
    prize4=prize2+200000*0.05;
    prize6=prize4+200000*0.03;
    prize10=prize6+400000*0.015;
    if(gain<=100000)
        prize=gain*0.1;
    else if(gain<=200000)
        prize=prize1+(gain-100000)*0.075;
    else if(gain<=400000)
        prize=prize2+(gain-200000)*0.05;
    else if(gain<=600000)
        prize=prize4+(gain-400000)*0.03;
    else if(gain<=1000000)
        prize=prize6+(gain-600000)*0.015;
    else
        prize=prize10+(gain-1000000)*0.01;
    printf("The prize is:%d\n",prize);
    return 0;
}将第六行int 改为double后结果出现错误,不管输入任何数,结果都为0!
搜索更多相关主题的帖子: long include problem please 
2013-04-09 15:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-403481-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.388442 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved