HDU 4493 Tutor (math AH)

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=4493


Problem Descriptionlilin 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 he average monthly money to decide whether continue or not. But she isn't good at calculation, so she's ask for your help. Lilin to calculate the average money and her earned per month.
Inputthe first line contain one integer T, means the total number of cases.
Every case would be twelve lines. Each line would contain the money she earned per month. Each number is positive and displayed to the penny. No dollar sign would be included.
Outputthe output is a single number and the average of money she earned for the twelve months. It'll be rounded to the nearest penny, preceded immediately by a dollar sign without tail zero. There'll be is 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.75100.00 100.00 100.00 100.00 100.00 10 0.00 100.00 100.00 100.00 100.00 100.00 100.00

Sample Output
  
    
   
       1581.42100
  
    

Source2013 ACM-ICPC Jilin Tonghua National Invitational--title reappearance

The code is as follows:

#include <cstdio> #include <cstring>int main () {    int t;    scanf ("%d", &t);    while (t--)    {        Double A, sum, ans;        sum = 0;        for (int i = 1; i <=; i++)        {            scanf ("%lf", &a);            sum + = A;        }        ans = sum/12.0;        int tt1 = ans*1000;        int tt2 = ans*100;        if (tt1%10 >= 5)//rounding        {            tt2+=1;        }        if (tt2%100 = = 0)//two X 0        {            printf ("$%.0lf\n", ans);        }        else if (tt2%10 = = 0)//a 0        {            printf ("$%.1lf\n", ans);        }        else        {            printf ("$%.2lf\n", ans);        }    }    return 0;} /*101.5551.5551.5551.5551.5551.5551.5551.5551.5551.5551.5551.555*/


HDU 4493 Tutor (math AH)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.