新手的问题就是多啊 问题到底出在哪?
/* 2.14 */#include<stdio.h>
int main(void)
{
const float revenue_per_150=4.5f;
short jansold=23500;
short febsold=19300;
short marsold=21600;
float revquarter=0.0f;
long quartersold=jansold+febsold+marsold;
printf("stock sold in\n jan: %d\n feb: %d\n mar: %d\n",
jansold,febsold,marsold);
printf("total stock sold in first quarter: %ld\n",quartersold);
revquarter=quartersold/150*revenue_per_150;
printf("sales revenue this quarter is:$%.2f\n",revquarter);
getch();
return 0;
}
输出结果因该是
stock sold in
jan:23500
feb:19300
mar:21600
total stock sold in first quarter:64400
sales revenue this quarter is :$1930.50
我完全照书上打的
可为什么到我实际执行
total stock sold in first quarter:-1136
sales revenue this quarter is :$-31.50
成两负数了啊????
[ 本帖最后由 y41699060 于 2011-5-9 20:37 编辑 ]