POJ 1004 Financial Management


1.テーマ情報
http://poj.org/problem?id=1004
Financial Management
Time Limit: 1000 MS
 
メモリLimit: 100000 K
Total Submissions: 92521
 
Acceepted: 45271
Description
Larry graduted this year and finally has.He's making a lot of money,ラrry has decided thaat he needs to grab hold hold of his finanatipotfolio and sosososososologh.Larry has has dededededed ththaat heheheneeeeeeeeeeeeeeeeeeeeeeeed d d d d d holdaab holdaab holdab holdab holdah h h h h h h h h h h h h h h h h h h h h holdaaaaaaah h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h h g a program to take his closing balANce from each of the past twelve montths and calculate his average account balance.
Input
The input will be twelve lineas.Each line will contain the closing balance of his bank account for a particular moneth.Each number will be positive and displayed to the penny.No dollar sign will be incled.
Output
The output will be a single number,the average of the closing balancs for the twelve mons.It will be rounded to the neart penny,preced immediately bya dollar sign,and folled bythe the plactwers ine e e e e e e e e e e e e e e the.the intfaoter ine e e e e e e e e e e e e e e e e e e e e e e e e intwint.infollatwint.the.the。
Sample Input
100.00
489.12
12454.12
1234.10
823.05
109.20
5.27
1542.25
839.18
83.99
1295.01
1.75
Sample Output
$1581.42
2.アルゴリズムの考え方
本題は基本的なテーマで、実質的には順次12個の浮動小数点を入力して、平均値を求めてもいいです。平均値の前に'米ドル'記号を追加して、小数点以下の2桁まで正確に入力してください。
3.参考コード
半年Cコードを書いていません。printfのフォーマット出力さえ忘れそうになりました。下のコードは典型的なアルゴリズムですが、メモリが多すぎます。
/*
  Name: POJ1004
  Author: chenbin
  Date: 08-10-12 18:07
  Description: http://poj.org/problem?id=1004
*/
#include <stdio.h>
int main()
{
    float penny = 0,sum = 0;
    int i = 0;
    for(i = 0 ; i <= 11;i++)
    {
        scanf("%f",&penny);
        sum += penny;
    }
    printf("$%.2f
",sum/12.0); return 0; }