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;

}



 

全部评论

相关推荐

牛客刘北:如果暑期实习是27届的话,你要晚一年才会毕业,企业为什么会等你呢?要搞清时间逻辑呀!27届现在实习只能是在暑假实习,这是日常实习,不是暑期实习。所以多去投日常实习吧,暑期实习肯定不会要你的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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