| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 615 人关注过本帖
标题:指针时钟
只看楼主 加入收藏
xyz_susan
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-10-4
收藏
 问题点数:0 回复次数:5 
指针时钟
这是一道指针题,模拟一个数字式时钟.可为什么不通,我找不到原因,请高手帮助.

#include"stdio.h"
struct clock
{
int hour;
int minute;
int second;
};
typedef struct lock CLOCK;
void update (CLOCK *t)
{
t->second++;
if(t->second==60)
{
t->second=0;
t->minute++;
}
if(t->minute==60)
{
t->minte=0;
t->hour++;
}
if(t->hour==24)
t->hour=0;
}
void display(CLOCK *t)
{
printf("*%d:%d:%d\r",t->hour,t->minute,t-.second);
}
void deplay()
{
int t;
for(t=0;t<10000;t++);
}
main()
{
int i;
CLOCK *time;
time->hour=time-?minute=time->second=0;
for(i=0;i<10000;i++)
{
update(time);
display(time);
delay(0;
}
}
搜索更多相关主题的帖子: 指针 时钟 
2006-11-06 19:57
C语言学习者
Rank: 4
等 级:贵宾
威 望:13
帖 子:1278
专家分:0
注 册:2006-9-26
收藏
得分:0 
式格有点乱,还有这种写法吗?time-&gt;hour=time-?minute=time-&gt;second=0;

谁有强殖装甲第二部,可以Q我460054868
2006-11-06 20:11
我不是郭靖
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:494
专家分:6
注 册:2006-10-4
收藏
得分:0 
#include"stdio.h"
struct clock
{
int hour;
int minute;
int second;
};
typedef struct clock CLOCK;
void update (CLOCK *t)
{
t->second++;
if(t->second==60)
{
t->second=0;
t->minute++;
}
if(t->minute==60)
{
t->minute=0;
t->hour++;
}
if(t->hour==24)
t->hour=0;
}
void display(CLOCK *t)
{
printf("%02d:%02d:%02d\r",t->hour,t->minute,t->second);
}
void deplay()
{
int t;
for(t=0;t<10000;t++);
}
main()
{
CLOCK a;
CLOCK *time=&a;
time->hour=time->minute=time->second=0;
for(;;)
{
update(time);
display(time);
deplay();
}
}

2006-11-06 20:12
hao0716
Rank: 4
等 级:业余侠客
威 望:1
帖 子:353
专家分:222
注 册:2006-4-11
收藏
得分:0 
.....LS的那是啥?变的也太快了吧

2006-11-07 13:28
dmshfut
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-11-7
收藏
得分:0 
#include"stdio.h"
struct clock
{
int hour;
int minute;
int second;
};
typedef struct clock CLOCK;
void update (CLOCK *t)
{
t->second++;
if(t->second==60)
{
t->second=0;
t->minute++;
}
if(t->minute==60)
{
t->minute=0;
t->hour++;
}
if(t->hour==24)
t->hour=0;
}
void display(CLOCK *t)
{
printf("%02d:%02d:%02d\r",t->hour,t->minute,t->second);
}
void deplay()
{
int t;
for(t=0;t<10000;t++);
}
main()
{
CLOCK a;
CLOCK *time=&a;
time->hour=time->minute=time->second=0;
for(;;)
{
update(time);
display(time);
deplay();
}
}
为什么到23秒就重新记数;
2006-11-07 17:06
xyz_susan
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-10-4
收藏
得分:0 

感谢诸位高手的帮助.

2006-11-08 22:25
快速回复:指针时钟
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014364 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved