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 }
  • 相关阅读:
    http 请求code状态码
    uni-app实现弹窗遮罩
    小程序分享报错 Cannot read property 'apply' of null;at page XXX onShareAppMessage function
    mac下出现xcrun: error导致git、svn无法使用的解决办法
    uniapp 小程序实现自定义底部导航栏(tarbar)
    Python2.X和Python3.X中Tkinter模块的文件对话框、下拉列表的不同
    Mac 设置git的template
    每天一点点之vue框架开发
    uni-app开发小程序-使用uni.switchTab跳转后页面不刷新的问题
    小程序实现微信朋友圈时间显示效果
  • 原文地址:https://www.cnblogs.com/kuangbin/p/3279623.html
Copyright © 2011-2022 走看看