闹钟代码
#include <bits/stdc++.h>
//嘿嘿!
using namespace std;
void sleep(double x)
{
x*=1000;
while(x)
{
x--;
}
}
int main()
{
while(1)
{
time_t now=time(0);
tm *ltm = localtime(&now);
cout<<"现在的时间是:";
cout<<ltm->tm_year+1900<<"年";
cout<<ltm->tm_mon+1<<"月";
cout<<ltm->tm_mday<<"日";
cout<<"星期";
switch(ltm->tm_wday)
{
case 0:{
cout<<"天";
break;
}
case 1:{
cout<"一";
break;
}
case 2:{
cout<<"二";
break;
}
case 3:{
cout<<"三";
break;
}
case 4:{
cout<<"四";
break;
}
case 5:{
cout<<"五";
break;
}
case 6:{
cout<<"六";
break;
}
}
cout<<ltm->tm_hour<<"时";
cout<<ltm->tm_min<<"分";
cout<<ltm->tm_sec<<"秒";
sleep(0.05);system("cls");
}
return 0;
}