如何实现钟表功能呢?

huaer89 2010-10-17 12:41:07
#include<stdio.h>
#include<conio.h>
#include<time.h>
void delay(int n);
void main()
{
int ia,ib,ic,id,ie,f;
for(ia=2010;ia<2012;ia++)
{
printf("\n\n\n\n\n\t%d 年",ia+1);
for(ib=0;ib<11;ib++)
{
printf("\n\n\n\n\n\t\t%d 月 ",ib+1);
for(ic=0;ic<29;ic++)
{
printf("\n\n\n\n\n\t\t\t%d 日 ",ic+1);
for(id=0;id<23;id++)
{
printf("\n\n\n\n\n\t\t\t\t%d : ",id+1);
for(ie=0;ie<59;ie++)
{
printf("\n\n\n\n\n\t\t\t\t\t%d : ",ie+1);
for(f=0;f<59;f++)
{
printf("\n\n\n\n\n\t\t\t\t\t\t%d ",f+1);
delay(1);
}
}
}
}
}
}
}
void delay(int n)
{
time_t start,end;
volatile long unsigned t=0;
start = time(NULL);
end = time(NULL);
while(difftime(end,start) < n )
{
end = time(NULL);
}
}
如何实现钟表功能啊?我的总是不能同时出现时分秒 就是年 月 日 时 : 分 : 秒 这样的
...全文
94 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Athenacle_ 2010-10-17
  • 打赏
  • 举报
回复
#include<stdio.h>
#include <stdlib.h>
#include<time.h>


void delay(int n);



void delay(int n){
time_t start,end;
volatile long unsigned t=0;
start = time(NULL);
end = time(NULL);
while(difftime(end,start) < n ) {
end = time(NULL);
}
}

int main(void){

struct tm *t;
time_t tim;
time_t *timer = &tim;
time(timer);
system("cls");
printf("%s", ctime(timer));

main();
return 0;
}

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧