#include "windows.h"
#include "iostream"
int main()
{
int minutes=0, seconds=0, hours=0;
while (1)
{
Sleep(1000);
system("cls");
seconds++;
if(seconds == 60)
{
minutes++;
seconds = 0;
}
if(minutes == 60)
{
hours++;
minutes = 0;
}
if(hours == 24)
{
hours = 0;
}
if(hours < 10 || minutes < 10 || seconds < 10)
{
if( hours < 10 && minutes < 10 && seconds < 10)
{
if(seconds % 2 != 0)
{
std::cout << "0" << hours << " " << "0" << minutes << " " << "0" << seconds;
}
else
{
std::cout << "0" << hours << " : " << "0" << minutes << " : " << "0" << seconds;
}
}
else
{
if(minutes < 10 && seconds < 10)
{
if(seconds % 2 != 0)
{
std::cout << hours << " " << "0" << minutes << " " << "0" << seconds;
}
else
{
std::cout << hours << " : " << "0" << minutes << " : " << "0" << seconds;
}
}
else
{
if( hours < 10 && seconds < 10)
{
if(seconds % 2 != 0)
{
std::cout << "0" << hours << " " << minutes << " " << "0" << seconds;
}
else
{
std::cout << "0" << hours << " : " << minutes << " : " << "0" << seconds;
}
}
else
{
if( hours < 10 && minutes < 10)
{
if(seconds % 2 != 0)
{
std::cout << "0" << hours << " " << "0" << minutes << " " << seconds;
}
else
{
std::cout << "0" << hours << " : " << "0" << minutes << " : " << seconds;
}
}
else
{
if( hours < 10)
{
if(seconds % 2 != 0)
{
std::cout << "0" << hours << " " << minutes << " " << seconds;
}
else
{
std::cout << "0" << hours << " : " << minutes << " : " << seconds;
}
}
}
}
}
}
}
else
{
if(seconds % 2 != 0)
{
std::cout << hours << " " << minutes << " " << seconds;
}
else
{
std::cout << hours << " : " << minutes << " : " << seconds;
}
}
}
return 0;
}
This code only displays a timer in the console, I don't know if this can be use for an actual aplication but if you want to see a timer in a console aplication, here you have the code.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.