admin管理员组文章数量:1559084
b - financial management
文章目录
- b - financial management
- 题目描述:
- 输入格式:
- 输出格式:
- 输入与输出样例:
- 思路分析:
- 代码:
题目描述:
larry graduated this year and finally has a job. he’s making a lot of money, but somehow never seems to have enough. larry has decided that he needs to grab hold of his financial portfolio and solve his financing problems. the first step is to figure out what’s been going on with his money. larry has his bank account statements and wants to see how much money he has. help larry by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.
输入格式:
the input will be twelve lines. each line will contain the closing balance of his bank account for a particular month. each number will be positive and displayed to the penny. no dollar sign will be included.
输出格式:
the output will be a single number, the average (mean) of the closing balances for the twelve months. it will be rounded to the nearest penny, preceded immediately by a dollar sign, and followed by the end-of-line. there will be no other spaces or characters in the output.
输入与输出样例:
思路分析:
这道题只是简单求12个值的平均值,但这道题考的是输入格式eof的运用,eof象征文件结束标志。
代码:
#include
double b[12];
double lemon()
{
int c=0;
double d=0;
while(scanf("%lf",&b[c])!=eof)
{
d=b[c];
c;
if(c==12)break;
}
return d;
}
void lemon2(double d)
{
printf("$%.2f",d/12);
}
int main()
{
double d;
d=lemon();
lemon2(d);
}
本文标签:
j9九游会老哥俱乐部交流区的版权声明:本文标题:b - financial management 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1727384298a1112245.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论