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;

}



 

全部评论

相关推荐

点赞 评论 收藏
分享
小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-15 17:24
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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