Untitled

 avatar
unknown
plain_text
3 years ago
954 B
0
Indexable
//17. Construir un reloj digital con el siguiente formato : HH : MM : SS.
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
    cout << "Bienvenidos al reloj" << endl;
    int hh = 0, mm = 0, ss = 0;
    while (hh <= 24)
    {
        ss = ss + 1;
        if (hh < 10)
        {
            cout << "0" << hh;
        }
        else
        {
            cout << hh;
        }
        if (mm < 10)
        {
            cout << ":0" << mm;
        }
        else
        {
            cout << ":";
        }
        if (ss < 10)
        {
            cout << ":0" << ss << endl;
        }
        else
        {
            cout << ":" << ss << endl;
        }

        if (ss >= 60)
        {
            mm = mm + 1;
            ss = 0;
        }
        if (mm >= 60)
        {
            hh = hh + 1;
            mm = 0;
        }
        Sleep(1000);
    }
    return 0;
}