Financial Management问题

Time Limit: 1000MS

 

Memory Limit: 10000K

Total Submissions: 190210

 

Accepted: 72165

Larrygraduated this year and finally has a job. He's making a lot of money, butsomehow never seems to have enough. Larry has decided that he needs to grabhold of his financial portfolio and solve his financing problems. The firststep is to figure out what's been going on with his money. Larry has his bankaccount statements and wants to see how much money he has. Help Larry bywriting a program to take his closing balance from each of the past twelvemonths and calculate his average account balance.

Input

Theinput will be twelve lines. Each line will contain the closing balance of hisbank account for a particular month. Each number will be positive and displayedto the penny. No dollar sign will be included.

Output

Theoutput will be a single number, the average (mean) of the closing balances forthe twelve months. It will be rounded to the nearest penny, preceded immediatelyby a dollar sign, and followed by the end-of-line. There will be no otherspaces or characters in the output.

Sample Input

100.00     489.12     12454.12   1234.10    823.05     109.20      5.271542.25    839.18      83.99      1295.01    1.75

Sample Output

$1581.42

 

程序代码:

#include<stdio.h>

int main()

{

    int i;        //i表示数组n[]的下标

    float n[12],sum=0.0; //浮点型数组n[]用于记录输入的12个数,sum表示12个数的和

    for(i=0;i<12;i++)    //for循环,连续输入12个数

    {

       scanf("%f",&n[i]);       //输入

       sum=sum+n[i];     //求和

    }

    printf("$%.2f\n",sum/12);   //输出平均值,.2f保留两位小数到一便士

    return 0;

}



 

全部评论

相关推荐

给🐭🐭个面试机会...:我擦seed✌🏻
点赞 评论 收藏
分享
不知道怎么取名字_:两个方向 1.简历针对性准备下 2.面试前也需要准备的 主要还是要看各个公司需求,看公司行业和岗位描述,那里面已经写了对技术的需求,一份简历,不可能和所有嵌入式岗位都匹配的
投递北京经纬恒润科技股份有限公司等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务