您的位置:

用c语言运行时钟的动画,用c语言运行时钟的动画

本文目录一览:

用C语言做数字时钟每走一秒响一次,求大神告诉源代码

“响一次”需要牵涉到图形编程中的音乐播放问题,需要自己下载图形编程相关库文件,具体实现请自己在TODO里添加播放音乐的代码

数字时钟的实现很简单,运用time.h相关函数即可

#includestdio.h

#includestdlib.h

#includetime.h

time_t oldt=-1;

struct tm *p;

bool Printdate()

{

time_t t=time(NULL);

if(t!=oldt)

{

oldt=t;

p=localtime(t);

system("cls");

printf("%d/%d/%d 周",1900+p-tm_year,1+p-tm_mon,p-tm_mday,p-tm_hour,p-tm_min,p-tm_sec); 

switch(p-tm_wday)

{

       case 1:printf("一");break;

       case 2:printf("二");break;

       case 3:printf("三");break;

       case 4:printf("四");break;

       case 5:printf("五");break;

       case 6:printf("六");break;

       case 7:printf("日");break;

 }  

printf(" %d:%02d:%02d     ", p-tm_hour, p-tm_min,  p-tm_sec);

return 1;

}

return 0;

}

main()

{

while(1)

    if(Printdate())

    {

    /*************TODO*************/

    /**For example: printf("\a");**/

    }

return 0;

}

C语言模拟动态时钟程序

#include "stdio.h"

#include "dos.h"

//#include windows.h

#include time.h

#define S2M_M2H 60

struct N

{

int hour;

int minute;

int second;

} mytime = {0,0,0};

int main()

{

time_t rt;

struct tm *t;

time ( rt );

t = localtime ( rt );

mytime.hour=t-tm_hour;

mytime.minute = t-tm_min;

mytime.second = t-tm_sec;

//1楼答得不错,你不会自己合直来么,我帮你合起来了

//以后我白天不能上网,晚上来答一两个就玩去了,这题如果可行,就采纳1楼的,我没功劳

for(; ; mytime.second++)

{

if(mytime.second==S2M_M2H)

{

mytime.minute++;

mytime.second=0;

if(mytime.minute==S2M_M2H)

{

mytime.hour++;

mytime.minute=0;

}

}

{

printf("\b\b\b\b\b\b\b\b%2d:%02d:%02d",mytime.hour,mytime.minute,mytime.second);

delay(1000);

}

}

return 0;

}

诚求一个C语言程序:模拟时钟转动程序

#include stdio.h

#include stdlib.h

#include time.h

//#include dos.h

#include conio.h

int main()

{

struct tm *curtime;

time_t t;

clock_t start;

double th_hour,th_min,th_sec;

do

{

printf("*********************************************

");

printf("** This is a simple clock program. **

");

printf("** **

");

printf("*********************************************

");

printf("The current time is:

");

t=time(0);

curtime=gmtime(t); /*得到当前系统时间*/

if((double)curtime-tm_hour=12) /*午前的处理*/

{

printf("AM ");

if((double)curtime-tm_hour10) printf("0"); /*十点之前在小时数前加零*/

printf("%.0f:",(double)curtime-tm_hour);

}

else /*午后的处理*/

{

printf("PM ");

if((double)curtime-tm_hour-1210) printf("0");

printf("%.0f:",(double)curtime-tm_hour-12);

}

if((double)curtime-tm_min10) printf("0");

printf("%.0f:",(double)curtime-tm_min);

if((double)curtime-tm_sec10) printf("0");

printf("%.0f",(double)curtime-tm_sec);

printf("

");

start=clock();

while(clock()-start1000);

// delay(1000); /*延时一秒后刷新*/

system("cls");

}while(!kbhit()); /* 按任一键退出 */

return 0;

}