等分中闲来无事,写了个倒计时程序

Posted by zhang on

#include <stdio.h>
#include <windows.h>
#include <time.h>
int main()
{
int year,mon,day,hour,min,sec;
printf(“year=”);//年
scanf(“%d”,&year);
printf(”
“);

printf(“mon=”);//月
scanf(“%d”,&mon);
printf(”
“);

printf(“day=”);//日
scanf(“%d”,&day);
printf(”
“);

printf(“hour=”);//时
scanf(“%d”,&hour);
printf(”
“);

printf(“min=”);//分
scanf(“%d”,&min);
printf(”
“);

printf(“sec=”);秒
scanf(“%d”,&sec);
printf(”
“);

struct tm fixDate;
fixDate.tm_year = year-1900;
fixDate.tm_mon = mon-1;
fixDate.tm_mday = day;
fixDate.tm_hour = hour;
fixDate.tm_min = min;
fixDate.tm_sec = sec;
time_t lt;
time_t fixTime_t = mktime(&fixDate);
while(1)
{
system(“cls”);
lt =time(NULL);
printf(“到2011年6月23号10:00剩余 %d 秒
“,fixTime_t-lt);
Sleep(980);
}

return 0;
}
dev-c++4.9.2.2测试通过

exe文件在


1 Comment

Comments are closed.