C语言高手帮我看看这段代码什么意思?

来源:百度知道 编辑:UC知道 时间:2024/09/22 17:26:42
#include <stdio.h>

int main(void)
{
const float Revenue_Per_150 = 4.5f;
short JanSold =23500; /* Stock sold in January */
short FebSold =19300; /* Stock sold in February */
short MarSold =21600; /* Stock sold in March */
float RevQuarter = 0.0f; /* Sales for the quarter */

long QuarterSold = JanSold+FebSold+MarSold; /* Calculate quarterly total */

/* Output monthly sales and total for the quarter */
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);

/* Calculate the total revenue for the quarter and output it */
RevQuarter = QuarterSold/150*Revenue_Per_150;
printf("Sales revenue this quarter is:$%.2f\n",RevQuarter);

以下是结果的翻译~~
砖块销量:
1月:23500(块)
2月:19300 (块)
3月:21600(块)
总共砖块销量在第一个季度:64400(即前3个月的总和)
销售额这个季度为:1932美元

这个程序实际上是计算一个季度砖块总销量,然后根据64400/150*4.5得出季度销售额

我解释的够清楚吧,
楼主一定要选我哦!

是关于统计1,2,3月份股票卖出的 情况
QuarterSold = JanSold+FebSold+MarSold是三个月的总数
RevQuarter 表示卖出总金额美元数

英文注释写的不是很明白么