Berikut ini adalah program jam digital di dev-c++ lumayan sulit namun tetap harus kita tengok, berikut dibawah ini input nyaa;
#include <iostream>
#include <ctime>
#include <sstream>
#include <functional>
#include <windows.h>
using namespace std;
struct Clock{int hours; int mins;int secs;};
int main(int argc, char *argv[]) {
tm * timeinfo;
Clock clock;
int jam,menit,detik;
time_t rawtime;
time ( &rawtime );
timeinfo = localtime( &rawtime );
clock.hours = timeinfo->tm_hour;
clock.secs = timeinfo->tm_sec;
clock.mins = timeinfo->tm_min;
do{
if (clock.hours<23){
if (clock.mins<59){
if (clock.secs<59){
clock.secs=clock.secs+1;
}
else{
clock.secs=0;
clock.mins=clock.mins+1;
}
}
else{
clock.mins=0;
clock.hours=clock.hours+1;
}
}
else{
clock.hours=0;
}
system("CLS");
cout<<clock.hours<<" : "<<clock.mins<<" : "<<clock.secs;
Sleep(999);
}while(true);
return 0;
}
maka nanti akan muncul output sbb;
Tidak ada komentar:
Posting Komentar