zoukankan      html  css  js  c++  java
  • HDU 4493 Tutor (水题)

    Tutor

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
    Total Submission(s): 47    Accepted Submission(s): 26


    Problem Description
    Lilin was a student of Tonghua Normal University. She is studying at University of Chicago now. Besides studying, she worked as a tutor teaching Chinese to Americans. So, she can earn some money per month. At the end of the year, Lilin wants to know his average monthly money to decide whether continue or not. But she is not good at calculation, so she ask for your help. Please write a program to help Lilin to calculate the average money her earned per month.
     
    Input
    The first line contain one integer T, means the total number of cases. 
    Every case will be twelve lines. Each line will contain the money she earned per month. Each number will be positive and displayed to the penny. No dollar sign will be included.
     
    Output
    The output will be a single number, the average of money she earned for the twelve months. It will be rounded to the nearest penny, preceded immediately by a dollar sign without tail zero. There will be no other spaces or characters in the output.
     
    Sample Input
    2 100.00 489.12 12454.12 1234.10 823.05 109.20 5.27 1542.25 839.18 83.99 1295.01 1.75 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00 100.00
     
    Sample Output
    $1581.42 $100
     
    Source
     
    Recommend
    liuyiding
     

    很水,注意去掉后面的0

     1 /* ***********************************************
     2 Author        :kuangbin
     3 Created Time  :2013/8/24 12:10:26
     4 File Name     :F:2013ACM练习比赛练习2013通化邀请赛1001.cpp
     5 ************************************************ */
     6 
     7 #include <stdio.h>
     8 #include <string.h>
     9 #include <iostream>
    10 #include <algorithm>
    11 #include <vector>
    12 #include <queue>
    13 #include <set>
    14 #include <map>
    15 #include <string>
    16 #include <math.h>
    17 #include <stdlib.h>
    18 #include <time.h>
    19 using namespace std;
    20 
    21 int main()
    22 {
    23     //freopen("in.txt","r",stdin);
    24     //freopen("out.txt","w",stdout);
    25     int T;
    26     scanf("%d",&T);
    27     while(T--)
    28     {
    29         double sum = 0;
    30         double a;
    31         for(int i = 0;i < 12;i++)
    32         {
    33             scanf("%lf",&a);
    34             sum += a;
    35         }
    36         sum /= 12;
    37         char str[1000];
    38         sprintf(str,"%.2f",sum);
    39         int len = strlen(str);
    40         if(str[len-2] == '0' && str[len-1] == '0')
    41             str[len-3] = 0;
    42         else if(str[len-1] == '0')
    43             str[len-1] = 0;
    44         printf("$%s
    ",str);
    45     }
    46     return 0;
    47 }
  • 相关阅读:
    webuploader web 大文件上传源代码
    poj 1703 Find them, Catch them
    poj 1308 Is It A Tree?
    hud 1785 畅通工程
    食物链 poj 1182
    poj 1611 The Suspects 并查集
    poj 2524 并查集 Ubiquitous Religions
    The Suspects 简单的并查集
    cf 621D
    hdu2159
  • 原文地址:https://www.cnblogs.com/kuangbin/p/3279623.html
Copyright © 2011-2022 走看看