除夕倒計時?
2017(除夕)實時倒計時多少秒
#include
#include
#include
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLK_TCK ;
while (clock() < endwait) {}
}
void main(){
time_t rawtime;
struct tm * target_time;
int d,h,m,s;
int k=0;
long double dif,r;
time_t now,t_end; // in sec
/* get current timeinfo and modify it to the user's choice */
time ( &rawtime );
target_time = localtime ( &rawtime ); // time_t to tm
// time struc and to time_t
target_time->tm_year = 2017 - 1900;
target_time->tm_mon= 1 - 1; // month - 1
target_time->tm_mday = 27 ; // day
target_time->tm_hour = 0 ; // hour
target_time->tm_min = 0 ;
target_time->tm_sec = 1 ;
t_end = mktime (target_time);
// printf("%s ",ctime(&t_end)); // print and check
while (k < 120)
{
now = time (NULL);
// printf("%s ",ctime(&now));
dif = difftime (t_end,now);
// printf( "%lf\n",dif);
d = (int) (dif / 86400.0);
r = dif - d * 86400.0;
h = (int) (r / 3600.0);
r = r - h * 3600.0;
m = (int) (r / 60.0);
r = r - m * 60.0;
s = (int) (r);
printf("%d--days %d--hours %d--min %d--sec\n",d,h,m,s);
(void) wait ( 2 ); // every 2 seconds print
k = k + 1;
};
}
倒計時程式,填入你的目標時間,例如 2017年,1月,27日,0時,0分,1秒。...餘下全文>>
除夕春節即將進入倒計時,為了傳統的節日慶祝一下,也許是中國人的一個良好開局。最後,關注各樣式的歡慶
看春節晚會