若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1143: Above Average

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,325

题目描述

It is said that 90% of frosh expect to be above average in their class. You are to provide a reality check.
The first line of standard input contains an integer C, the number of test cases. C data sets follow. Each data set begins with an integer, N, the number of people in the class (1 <= N <= 1000). N integers follow, separated by spaces or newlines, each giving the final grade (an integer between 0 and 100) of a student in the class. For each case you are to output a line giving the percentage of students whose grade is above average, rounded to 3 decimal places.

输入

暂无

输出

暂无

样例输入

5
5 50 50 70 80 100
7 100 95 90 80 70 60 50
3 70 90 80
3 70 90 81
9 100 99 98 97 96 95 94 93 91

样例输出

40.000%
57.143%
33.333%
66.667%
55.556%

参考代码

#include <stdio.h>
#include <string.h>
char *x[] = {
"WET","0",
"UTC","0",
"GMT","0",
"BST","+1",
"IST","+1",
"WEST","+1",
"CET","+1",
"CEST","+2",
"EET","+2",
"EEST","+3",
"MSK","+3",
"MSD","+4",
"AST","-4",
"ADT","-3",
"NST","-3.5",
"NDT","-2.5",
"EST","-5",
"EDT","-4",
"CST","-6",
"CDT","-5",
"MST","-7",
"MDT","-6",
"PST","-8",
"PDT","-7",
"HST","-10",
"AKST","-9",
"AKDT","-8",
"AEST","+10",
"AEDT","+11",
"ACST","+9.5",
"ACDT","+10.5",
"AWST","+8",
"",""};
int i,j,k,h,m,n,N,time;
char buf[100];
double off;
main() 
{
    scanf("%d",&N);
    while (N--) 
    {
        scanf(" %s",buf);
        if (!strcmp(buf,"noon")) time = 12*60; else if (!strcmp(buf,"midnight")) time = 0; else 
        {
            sscanf(buf,"%d:%d",&h,&m);
            if (h == 12) h = 0;
            time = h*60 + m;
            scanf(" %s",buf);
            if (!strcmp(buf,"p.m.")) time += 12*60;
        }
        scanf(" %s",buf);
        for (i=0;*x[i] && strcmp(x[i],buf);i++);
        if (strcmp(x[i],buf)) printf("oops:  <<<%s>>>n",buf);
      sscanf(x[i+1],"%lf",&off);
      time -= 60 * off; 
      scanf(" %s",buf);
      for (i=0;*x[i] && strcmp(x[i],buf);i++);
      if (strcmp(x[i],buf)) printf("oops:  %sn",buf);
      sscanf(x[i+1],"%lf",&off);
      time += 60 * off; 
      time = (time + 24*60) % (24*60);
      if (time == 0) printf("midnightn");
      else if (time == 12 * 60) printf("noonn");
      else {
         h = time/60%12;
         if (h == 0) h = 12;
         m = time%60;
         printf("%d:%02d %sn",h,m,time>12*60?"p.m.":"a.m.");
      }
   }
}

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip 原站点 Dreams孤独患者
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist