zoukankan      html  css  js  c++  java
  • [恢]hdu 1234

    2011-12-19 17:24:45

    地址:http://acm.hdu.edu.cn/showproblem.php?pid=1234

    题意:每天有n个人签到和离开,问最早到的和最后离开的人的名字。水。

    代码:

    # include <stdio.h>
    # include <string.h>


    typedef struct tm{
    int h, m, s ;
    }tm ;


    int isless(tm t1, tm t2)
    {
    if (t1.h != t2.h) return t1.h < t2.h ;
    if (t1.m != t2.m) return t1.m < t2.m ;
    return t1.s < t2.s ;
    }


    int ismore (tm t1, tm t2)
    {
    if (t1.h != t2.h) return t1.h > t2.h ;
    if (t1.m != t2.m) return t1.m > t2.m ;
    return t1.s > t2.s ;
    }


    int main ()
    {
    int T, n, i ;
    char s1[20], s2[20], name[20] ;
    tm t1, t2, ts, te ;
    scanf ("%d%*c", &T) ;
    while (T--)
    {
    scanf ("%d%*c", &n) ;
    scanf ("%s %d:%d:%d %d:%d:%d%*c",
    s1, &ts.h, &ts.m, &ts.s, &te.h, &te.m, &te.s) ;
    strcpy (s2, s1) ;

    for (i = 1 ; i < n ; i++)
    {
    scanf ("%s %d:%d:%d %d:%d:%d%*c", name,
    &t1.h, &t1.m, &t1.s, &t2.h, &t2.m, &t2.s) ;
    if (isless(t1, ts))
    {
    ts = t1 ;
    strcpy (s1, name) ;
    }
    if (ismore(t2, te))
    {
    te = t2 ;
    strcpy (s2, name) ;
    }
    }
    printf ("%s %s\n", s1, s2) ;
    }
    return 0 ;
    }



  • 相关阅读:
    es6类
    ES6模块化
    es6之常/变量
    es6之结构赋值
    es6之箭头函数、rest函数
    es6的新方法
    数组的使用方法
    Vue接口调用问题
    监听器和计算属性
    Vue路由
  • 原文地址:https://www.cnblogs.com/lzsz1212/p/2315234.html
Copyright © 2011-2022 走看看