zoukankan      html  css  js  c++  java
  • L1-018 大笨钟 (10分)

    开始天梯赛专项训练

    微博上有个自称“大笨钟V”的家伙,每天敲钟催促码农们爱惜身体早点睡觉。不过由于笨钟自己作息也不是很规律,所以敲钟并不定时。一般敲钟的点数是根据敲钟时间而定的,如果正好在某个整点敲,那么“当”数就等于那个整点数;如果过了整点,就敲下一个整点数。另外,虽然一天有 2424 小时,钟却是只在后半天敲 1∼121∼12 下。例如在 23:0023:00 敲钟,就是“当当当当当当当当当当当”,而到了 23:0123:01 就会是“当当当当当当当当当当当当”。在午夜 00:0000:00 到中午 12:0012:00 期间(端点时间包括在内),笨钟是不敲的。
    下面就请你写个程序,根据当前时间替大笨钟敲钟。

    输入格式:

    输入第一行按照 hh:mm 的格式给出当前时间。其中 hh 是小时,在 0000 到 2323 之间;mm 是分钟,在 0000 到 5959 之间。

    输出格式:

    根据当前时间替大笨钟敲钟,即在一行中输出相应数量个 Dang。如果不是敲钟期,则输出:
    Only hh:mm. Too early to Dang.
    其中 hh:mm 是输入的时间。

    输入样例1:

    19:05
    

    输出样例1:

    DangDangDangDangDangDangDangDang
    

    输入样例2:

    07:05
    

    输出样例2:

    Only 07:05.  Too early to Dang.
    

    代码:

    // Author : RioTian
    // Time : 20/10/28
    #include <bits/stdc++.h>
    using namespace std;
    int h, m;
    char x;
    int main() {
        cin >> h >> x >> m;
        if (h < 12 || (h == 12 && !m)) {
            cout << "Only " << setw(2) << setfill('0') << h << ':' << setw(2)
                 << setfill('0') << m << ".  Too early to Dang." << endl;
            return 0;
        }
        h += (m > 0) - 12;
        for (int i = 1; i <= h; i++) cout << "Dang";
        return cout << endl, 0;
    }
    

    The desire of his soul is the prophecy of his fate
    你灵魂的欲望,是你命运的先知。

  • 相关阅读:
    Html禁止粘贴 复制 剪切
    表单标签
    自构BeanHandler(用BeansUtils)
    spring配置中引入properties
    How Subcontracting Cockpit ME2ON creates SD delivery?
    cascadia code一款很好看的微软字体
    How condition value calculated in sap
    Code in SAP query
    SO Pricing not updated for partial billing items
    Javascript learning
  • 原文地址:https://www.cnblogs.com/RioTian/p/13893201.html
Copyright © 2011-2022 走看看