| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 446 人关注过本帖
标题:c语言小题
只看楼主 加入收藏
奥巴马
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2009-2-21
结帖率:100%
收藏
已结贴  问题点数:15 回复次数:5 
c语言小题
【程序2】
题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高
   于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提
   成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于
   40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于
   100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?
1.程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。      
2.程序源代码:
main()
{
long int i;
int bonus1,bonus2,bonus4,bonus6,bonus10,bonus;
scanf("%ld",&i);
bonus1=100000*0.1;bonus2=bonus1+100000*0.75;
bonus4=bonus2+200000*0.5;
bonus6=bonus4+200000*0.3;
bonus10=bonus6+400000*0.15;
 if(i<=100000)
  bonus=i*0.1;
 else if(i<=200000)
     bonus=bonus1+(i-100000)*0.075;
    else if(i<=400000)
        bonus=bonus2+(i-200000)*0.05;
       else if(i<=600000)
           bonus=bonus4+(i-400000)*0.03;
          else if(i<=1000000)
              bonus=bonus6+(i-600000)*0.015;
             else
              bonus=bonus10+(i-1000000)*0.01;
printf("bonus=%d",bonus);
}  
-编译时出很多错,如下
----Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
D:\c语言程序\vc++相关\Cpp1.cpp(8) : warning C4244: '=' : conversion from 'const double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(8) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(9) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(10) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(11) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(12) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(12) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(13) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(13) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(13) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(13) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(13) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(14) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(14) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(15) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(16) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(17) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(18) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(19) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(20) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(21) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(21) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(21) : error C2018: unknown character '0xa1'
D:\c语言程序\vc++相关\Cpp1.cpp(21) : fatal error C1003: error count exceeds 100; stopping compilation
Error executing cl.exe.

Cpp1.obj - 102 error(s), 9 warning
怎么回事啊,那里错了?
搜索更多相关主题的帖子: c语言 
2010-03-17 21:56
mikelr
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:67
专家分:161
注 册:2010-3-17
收藏
得分:0 
int bonus1,bonus2,bonus4,bonus6,bonus10,bonus;

改成 float


printf("bonus=%d",bonus);
改成:
printf("bonus=%f",bonus);
2010-03-17 22:08
奥巴马
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2009-2-21
收藏
得分:0 
不行啊,还是有102个错误和8个警告
2010-03-17 22:13
mikelr
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:67
专家分:161
注 册:2010-3-17
收藏
得分:0 
你这段代码是不是从网上COPY来的啊。
你还是在编辑器里,用手从新输入一次。
2010-03-17 22:28
lixnkei
Rank: 4
来 自:樱之国度
等 级:业余侠客
帖 子:133
专家分:227
注 册:2008-5-13
收藏
得分:15 
这代码好眼熟。。。。是那个C语言入门与提高里面的吧。。。。刚好我修正了,给你一份吧。
程序代码:
# include <stdio.h>

int main(void)
{
    long int i;
    double bonus1,bonus2,bonus4,bonus6,bonus10,bonus;
   
    scanf("%ld",&i);
   
    bonus1=100000*0.1;
    bonus2=bonus1+100000*0.75;
    bonus4=bonus2+200000*0.5;
    bonus6=bonus4+200000*0.3;
    bonus10=bonus6+400000*0.15;
   
    if(i<=100000)
    {
        bonus=i*0.1;
    }
    else if(i<=200000)
    {
        bonus=bonus1+(i-100000)*0.075;
    }
    else if(i<=400000)
    {
        bonus=bonus2+(i-200000)*0.05;
    }
    else if(i<=600000)
    {
        bonus=bonus4+(i-400000)*0.03;
    }
    else if(i<=1000000)
    {
        bonus=bonus6+(i-600000)*0.015;
    }
    else
    {
        bonus=bonus10+(i-1000000)*0.01;
    }
   
    printf("bonus=%lf",bonus);
   
    return 0;
}  





[ 本帖最后由 lixnkei 于 2010-3-17 22:52 编辑 ]


老师说:会写代码的人多如牛毛,但写得很规范的却不多。代码要规范,养成好习惯~!
2010-03-17 22:44
树上月
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:114
专家分:154
注 册:2010-1-6
收藏
得分:0 
这样搞一下就没有问题了!!
在敲代码的过程中注意排版!!整齐一些好看些!!
在Vc++下没有问题
#include<stdio.h>
main()
{
    long int i;
    int bonus1,bonus2,bonus4,bonus6,bonus10,bonus;
    scanf("%ld",&i);
    bonus1=100000*0.1;bonus2=bonus1+100000*0.75;
    bonus4=bonus2+200000*0.5;
    bonus6=bonus4+200000*0.3;
    bonus10=bonus6+400000*0.15;
    if(i<=100000)
        bonus=i*0.1;
    else if(i<=200000)
        bonus=bonus1+(i-100000)*0.075;
    else if(i<=400000)
        bonus=bonus2+(i-200000)*0.05;
    else if(i<=600000)
        bonus=bonus4+(i-400000)*0.03;
    else if(i<=1000000)
        bonus=bonus6+(i-600000)*0.015;
    else
        bonus=bonus10+(i-1000000)*0.01;
    printf("bonus=%d",bonus);
  return 0;
}

每一个不曾起舞的日子,都是对未来的一种辜负......
2010-03-17 22:56
快速回复:c语言小题
数据加载中...
 
   



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

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