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 }
  • 相关阅读:
    Android中对同一个TextView设置不同字体样式
    C++之new和malloc区别
    cocos2dx 在android平台打开文件问题
    基于物联网操作系统HelloX的智慧家庭体系架构
    密码学:SHA1加密算法详解
    Android中最简单的分享功能
    Android设置ProgressBar的前景和背景及其在多线程中的刷新
    【有明信息】虚实之间 ---关于企业架构是与非的探讨
    5.1.1 读取Redis 数据
    hdr(host), hdr_beg(host) , path_beg
  • 原文地址:https://www.cnblogs.com/kuangbin/p/3279623.html
Copyright © 2011-2022 走看看