1026. 程序运行时间(15)

原题: https://www.patest.cn/contests/pat-b-practise/1026

实现思路: 就是转换输入格式的问题, 给秒转成"时分秒"显示格式.

完整代码:

#include <stdio.h>

int main (void) {
    float CLK_TCK = 100.0;
    int c1;
    int c2;
    int source;
    int h = 0;
    int m = 0;
    int s = 0;

    scanf("%d %d", &c1, &c2);
    source = (int)((c2 - c1) / CLK_TCK + 0.5);
    h = source / 3600;
    m = (source - h * 3600) / 60;
    s = source - h * 3600 - m * 60;
    printf("%02d:%02d:%02d\n", h, m, s);

    return 0;
}
posted @ 2017-11-12 21:50  阿胜4K  阅读(254)  评论(0编辑  收藏  举报