zoukankan      html  css  js  c++  java
  • UVA 11945 Financial Management 水题

    Financial Management

    Time Limit: 1 Sec  Memory Limit: 256 MB

    题目连接

    acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=20184

    Description

    Michael graduated of ITESO this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Michael has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out what's been going on with his money.

    Michael has his bank account statements and wants to see how much money he has. Help Michael by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.

    Input

    The first line of input contains a single integer N, ( 1$ le$N$ le$100) which is the number of datasets that follow.

    Each dataset consists of twelve lines. Each line will contain the closing balance of his bank account for a particular month. Each number will be positive and displayed to the penny. No dollar sign will be included.


    Output

    For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, a character `$', and a single number, the average (mean) of the closing balances for the twelve months. It will be rounded to the nearest penny.


    Note: Used comma (,) to separate the thousands.


    Sample Input

    1 
    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

    1 $1,581.42

    HINT

    题意

            啊,给你十二个月的钱,然后求平均钱数,注意在千位打逗号

    题解:

      加起来除以12咯

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 200001
    #define mod 10007
    #define eps 1e-9
    //const int inf=0x7fffffff;   //无限大
    const int inf=0x3f3f3f3f;
    /*
    
    */
    //**************************************************************************************
    inline ll read()
    {
        int x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    int buf[10];
    inline void write(int i) {
      int p = 0;if(i == 0) p++;
      else while(i) {buf[p++] = i % 10;i /= 10;}
      for(int j = p-1; j >=0; j--) putchar('0' + buf[j]);
      printf("
    ");
    }
    int main()
    {
        int t=read();
        for(int cas=1;cas<=t;cas++)
        {
            double sum=0;
            double x=0;
            for(int i=0;i<12;i++)
            {
                cin>>x;
                sum+=x;
            }
            sum/=12;
            int a=(int)(sum/1000);
            sum-=a*1000;
            if(a>0)
                printf("%d $%d,%.2f
    ",cas,a,sum);
            else
                printf("%d $%.2f
    ",cas,sum);
        }
    }
  • 相关阅读:
    MYSQL索引
    MYSQL 外键 on语句 多表查询
    MYSQL用户管理
    MYSQL数据类型 表基本操作 表记录增删改 单表查询
    JQuery 引用方式
    JQuery 元素操作 each循环
    Android EditText方框验证码 短信验证码攻略
    android MVP模式介绍与实战
    一些不错的Android开源音视频播放器
    Android可伸缩布局-FlexboxLayout(支持RecyclerView集成)
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4388285.html
Copyright © 2011-2022 走看看