1.17hien time oclock system
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<iostream.h>
void displaytime(void);
void main()
{
clrscr();
cout<<"
Chuong trinh hien thi gio he thong.";
cout<<"
\t(nhan mot phim bat ki de giam toc do cap nhat thoi gian 8 lan)";
cout<<"
\t(nhan them mot phim de ket thuc chuong trinh)
";
/*Tang toc len 8 lan*/
outportb(0x43,0x34); // tu dieu khien
outportb(0x40,0x00); // byte thap
outportb(0x40,0x20); // byte cao
displaytime();
/*Toc do binh thuong*/
outportb(0x43,0x34); // tu dieu khien
outportb(0x40,0x00); // byte thap
outportb(0x40,0x00); // byte cao
displaytime();
exit(1);
}
void displaytime(void)
{
struct dostime_t time;
while(1)
{
_dos_gettime (&time); /* doc thoi gian */
/* Hien thoi gian theo dinh dang gio:phut:giay:phan tram giay */
printf("\r%i:%i:%i,%i",time.hour,time.minute,time.second,time.hsecond);
if(kbhit())
{
getch();
return;
}
}
}
Bạn đang đọc truyện trên: Truyen4U.Com