我是个新手,请各位大牛看一下我这个系统存在的问题

u010306446 2013-04-30 11:21:06
# include "stdio.h"
# include "conio.h"

void hehe (int)
{
int x,choice ;
if(choice <= 100000)
{
x = 100000 * 0.1;;
}
else if(choice > 100000 && choice <200000)
{
x = (100000 * 0.1) + (choice - 100000)*0.075;
}
else if(choice >=200000 && choice <400000)
{
x = (100000 * 0.1) + (200000 - 100000)*0.075 + (choice - 200000)*0.05;
}
else if(choice >=400000 && choice <600000)
{
x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (choice - 400000)*0.03;
}
else if(choice >=600000 && choice <1000000)
{
x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(choice - 600000)*0.015 ;
}
else
{
x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(1000000 - 600000)*0.015 + (choice -1000000)*0.01;
}

}
int main ()
{
int choice ;
int x;
printf("你输入公司单月的利润:");
scanf("%d",choice);
hehe(choice);
printf("%f\n",x);
return 0;
}
...全文
208 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
就是那个党伟 2013-05-03
  • 打赏
  • 举报
回复
你数据有点大,各种丢失。
zy47154683 2013-05-03
  • 打赏
  • 举报
回复
# include "stdio.h" # include "conio.h" int hehe (int choice ) { int x; if(choice <= 100000) { x = 100000 * 0.1;; } else if(choice > 100000 && choice <200000) { x = (100000 * 0.1) + (choice - 100000)*0.075; } else if(choice >=200000 && choice <400000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (choice - 200000)*0.05; } else if(choice >=400000 && choice <600000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (choice - 400000)*0.03; } else if(choice >=600000 && choice <1000000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(choice - 600000)*0.015 ; } else { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(1000000 - 600000)*0.015 + (choice -1000000)*0.01; } return x; } int main () { int choice ; int x; printf("你输入公司单月的利润:"); scanf("%d",&choice); x=hehe(choice); printf("%f\n",x); return 0; } 我也是新手,一起学习,看看行不行。
赵4老师 2013-05-03
  • 打赏
  • 举报
回复
常量也有类型! 100000和100000.0不是同一种类型的常量。
buyong 2013-05-03
  • 打赏
  • 举报
回复
1. scanf("%d",choice); //wrong should be: scanf("%d",&choice); // it needs the address of a var 2. hehe(choice); //wrong, because you do not get the return value from the function, should be: x=hehe(choice); 3 void hehe (int){.....} //wrong, hehe function should have a return value for x; should be: int hehe(int choice) { int x; ........ return x; }
neutral creature 2013-05-03
  • 打赏
  • 举报
回复
引用 楼主 u010306446 的回复:
# include "stdio.h" # include "conio.h" void hehe (int)//修改为int hehe(int) { int x,choice ; if(choice <= 100000) { x = 100000 * 0.1;; } else if(choice > 100000 && choice <200000) { x = (100000 * 0.1) + (choice - 100000)*0.075; } else if(choice >=200000 && choice <400000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (choice - 200000)*0.05; } else if(choice >=400000 && choice <600000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (choice - 400000)*0.03; } else if(choice >=600000 && choice <1000000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(choice - 600000)*0.015 ; } else { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(1000000 - 600000)*0.015 + (choice -1000000)*0.01; } //加一句return x; } int main () { int choice ; int x;//修改为float x; printf("你输入公司单月的利润:"); scanf("%d",choice);//修改为scanf("%d", &choice); hehe(choice);//修改为x = hehe(choice); printf("%f\n",x); return 0; }
在你的程序中做了修改,不懂再问我,请加分,thanks!
折翼断JJ 2013-04-30
  • 打赏
  • 举报
回复
//是要改的 # include <stdio.h> # include <conio.h> int hehe (float k)// { float x, choice;// if(choice <= 100000) { x = 100000 * 0.1; } else if(choice > 100000 && choice <200000) { x = (100000 * 0.1) + (choice - 100000)*0.075; } else if(choice >=200000 && choice <400000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (choice - 200000)*0.05; } else if(choice >=400000 && choice <600000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (choice - 400000)*0.03; } else if(choice >=600000 && choice <1000000) { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(choice - 600000)*0.015 ; } else { x = (100000 * 0.1) + (200000 - 100000)*0.075 + (400000 - 200000)*0.05 + (600000 - 400000)*0.03 +(1000000 - 600000)*0.015 + (choice -1000000)*0.01; } return x;// } int main () { float x,choice ; printf("你输入公司单月的利润:"); scanf("%f",&choice);// x=hehe(choice);// printf("%f\n",x); return 0; }

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧