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;

}



 

全部评论

相关推荐

11-05 07:29
贵州大学 Java
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务