LoginSignup
0
0

More than 5 years have passed since last update.

at coder beginner 012

Posted at

B
高橋君は、お風呂で湯船に浸かった秒数を数える習慣があります。
今日は、高橋君は湯船で N 秒まで数えました。
しかし、秒だと解りにくいので、何時間何分何秒、という形に直したいです。
秒数 N が与えられるので、 hh: mm :ss の形式に変換しなさい。

#include <iostream>

using namespace std;


int main() {
    int N;
    cin >> N;
    int a = N / 3600;
    int b = N % 3600;
    int c = b % 60;
    b /= 60;

    if (a<10) {
        cout << '0'<< a << ':';
    }
    else {
        cout << a << ":";
    }
    if (b<10) {
        cout << '0'<< b << ':';
    }
    else {
        cout << b << ':';
    }
    if (c<10) {
        cout << '0' << c << endl;
    }
    else {
        cout << c << endl;
    }
    return 0;
}

普通。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0