四位数字时钟设计 C语言程序
要实现的功能就和平时我们用的电子表差不多,只是小时和分钟用四位数码管显示出来,而秒针则用发光二极管的“亮”与“灭”来显示,开关S1,S2分别调试小时和分钟。图在下面劳驾各...
要实现的功能就和平时我们用的电子表差不多,只是小时和分钟用四位数码管显示出来,而秒针则用发光二极管的“亮”与“灭”来显示,开关S1,S2分别调试小时和分钟。图在下面
劳驾各位高手,希望是懂电子技术的大哥大姐。不胜感激!
自己编出来代入运行仿真显示的是乱码??
怎么运行会有错误啊
Build target "Target 1"
compiling 520.c...
.\520.c(4):error 318:can not open file"conio.h"
.\520.c(5):error 318:can not open file"time.h"
.\520.c(13):error c129:missing ";"bfore "now"
Target not created 展开
劳驾各位高手,希望是懂电子技术的大哥大姐。不胜感激!
自己编出来代入运行仿真显示的是乱码??
怎么运行会有错误啊
Build target "Target 1"
compiling 520.c...
.\520.c(4):error 318:can not open file"conio.h"
.\520.c(5):error 318:can not open file"time.h"
.\520.c(13):error c129:missing ";"bfore "now"
Target not created 展开
5个回答
展开全部
两个参看啊:
第一个:
算法:将当前时间显示到屏幕,当时间发生变化时,清屏,显示新的时间(当有键盘操作时退出程序)。
显示时间格式:小时:分钟:秒
/* DEV C++ Win XP*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
typedef struct
{
int x;
int y;
}Point;
time_t now;
struct tm *pt,t1,t2;
int printpoint(Point p)
{
Point p1;
p1.x=p.x+2; p1.y=p.y+4;
gotoxy(p1.x,p1.y); printf("%c%c",2,2);
gotoxy(p1.x, p1.y+1); printf("%c%c",2,2);
p1.y+=4;
gotoxy(p1.x,p1.y); printf("%c%c",2,2);
gotoxy(p1.x,p1.y+1); printf("%c%c",2,2);
return 0;
}
int print0(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else
printf("%c%4s%c",2," ",2);
}
return 0;
}
int print1(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
printf("%5s%c"," ",2);
}
return 0;
}
int print2(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%5s%c"," ",2);
else
printf("%c",2);
}
return 0;
}
int print3(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else
printf("%5s%c"," ",2);
}
return 0;
}
int print4(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i<6) printf("%c%4s%c",2," ",2);
else if(i==6)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else printf("%5s%c"," ",2);
}
return 0;
}
int print5(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%c",2);
else
printf("%5s%c"," ",2);
}
return 0;
}
int print6(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%c",2);
else
printf("%c%4s%c",2," ",2);
}
return 0;
}
int print7(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0) printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else printf("%5s%c"," ",2);
}
return 0;
}
int print8(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else printf("%c%4s%c",2," ",2);
}
return 0;
}
int print9(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%c%4s%c",2," ",2);
else
printf("%5s%c"," ",2);
}
return 0;
}
int clear(Point p)
{
int i=0;
for(;i<13;i++)
gotoxy(p.x,p.y+i); printf("%16s"," ");
return 0;
}
int printtime(Point p, int n)
{
int a,b;
Point pp;
a=n/10, b=n%10;
pp.x=p.x+8, pp.y=p.y;
switch(a)
{
case 0: print0(p); break;
case 1: print1(p); break;
case 2: print2(p); break;
case 3: print3(p); break;
case 4: print4(p); break;
case 5: print5(p); break;
}
switch(b)
{
case 0: print0(pp); break;
case 1: print1(pp); break;
case 2: print2(pp); break;
case 3: print3(pp); break;
case 4: print4(pp); break;
case 5: print5(pp); break;
case 6: print6(pp); break;
case 7: print7(pp); break;
case 8: print8(pp); break;
case 9: print9(pp); break;
}
return 0;
}
int main()
{
Point phour, pmin, psec,point1,point2;
phour.x=9, pmin.x=32, psec.x=55;
phour.y=pmin.y=psec.y=7;
point1.x=25, point2.x=49;
point1.y=point2.y=7;
clrscr();
textbackground(BLUE);
textcolor(YELLOW);
now=time(0);
pt=localtime(&now);
t1=*pt;
printtime(phour, t1.tm_hour);
printpoint(point1);
printtime(pmin, t1.tm_min);
printpoint(point2);
printtime(psec, t1.tm_sec);
while(1)
{
now=time(0);
pt=localtime(&now);
t2=*pt;
if(t2.tm_sec!=t1.tm_sec)
{
t1=t2;
clrscr();
printtime(phour, t1.tm_hour);
printpoint(point1);
printtime(pmin, t1.tm_min);
printpoint(point2);
printtime(psec, t1.tm_sec);
}
if(bioskey(1)==0) continue;
else exit(0);
}
return 0;
}
晕,还有一份字数限制了
第一个:
算法:将当前时间显示到屏幕,当时间发生变化时,清屏,显示新的时间(当有键盘操作时退出程序)。
显示时间格式:小时:分钟:秒
/* DEV C++ Win XP*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
typedef struct
{
int x;
int y;
}Point;
time_t now;
struct tm *pt,t1,t2;
int printpoint(Point p)
{
Point p1;
p1.x=p.x+2; p1.y=p.y+4;
gotoxy(p1.x,p1.y); printf("%c%c",2,2);
gotoxy(p1.x, p1.y+1); printf("%c%c",2,2);
p1.y+=4;
gotoxy(p1.x,p1.y); printf("%c%c",2,2);
gotoxy(p1.x,p1.y+1); printf("%c%c",2,2);
return 0;
}
int print0(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else
printf("%c%4s%c",2," ",2);
}
return 0;
}
int print1(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
printf("%5s%c"," ",2);
}
return 0;
}
int print2(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%5s%c"," ",2);
else
printf("%c",2);
}
return 0;
}
int print3(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else
printf("%5s%c"," ",2);
}
return 0;
}
int print4(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i<6) printf("%c%4s%c",2," ",2);
else if(i==6)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else printf("%5s%c"," ",2);
}
return 0;
}
int print5(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%c",2);
else
printf("%5s%c"," ",2);
}
return 0;
}
int print6(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%c",2);
else
printf("%c%4s%c",2," ",2);
}
return 0;
}
int print7(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0) printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else printf("%5s%c"," ",2);
}
return 0;
}
int print8(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else printf("%c%4s%c",2," ",2);
}
return 0;
}
int print9(Point p)
{
int i=0;
for(;i<13;i++)
{
gotoxy(p.x+1, p.y+i);
if(i==0||i==6||i==12)
printf("%c%c%c%c%c%c",2,2,2,2,2,2);
else if(i>0&&i<6)
printf("%c%4s%c",2," ",2);
else
printf("%5s%c"," ",2);
}
return 0;
}
int clear(Point p)
{
int i=0;
for(;i<13;i++)
gotoxy(p.x,p.y+i); printf("%16s"," ");
return 0;
}
int printtime(Point p, int n)
{
int a,b;
Point pp;
a=n/10, b=n%10;
pp.x=p.x+8, pp.y=p.y;
switch(a)
{
case 0: print0(p); break;
case 1: print1(p); break;
case 2: print2(p); break;
case 3: print3(p); break;
case 4: print4(p); break;
case 5: print5(p); break;
}
switch(b)
{
case 0: print0(pp); break;
case 1: print1(pp); break;
case 2: print2(pp); break;
case 3: print3(pp); break;
case 4: print4(pp); break;
case 5: print5(pp); break;
case 6: print6(pp); break;
case 7: print7(pp); break;
case 8: print8(pp); break;
case 9: print9(pp); break;
}
return 0;
}
int main()
{
Point phour, pmin, psec,point1,point2;
phour.x=9, pmin.x=32, psec.x=55;
phour.y=pmin.y=psec.y=7;
point1.x=25, point2.x=49;
point1.y=point2.y=7;
clrscr();
textbackground(BLUE);
textcolor(YELLOW);
now=time(0);
pt=localtime(&now);
t1=*pt;
printtime(phour, t1.tm_hour);
printpoint(point1);
printtime(pmin, t1.tm_min);
printpoint(point2);
printtime(psec, t1.tm_sec);
while(1)
{
now=time(0);
pt=localtime(&now);
t2=*pt;
if(t2.tm_sec!=t1.tm_sec)
{
t1=t2;
clrscr();
printtime(phour, t1.tm_hour);
printpoint(point1);
printtime(pmin, t1.tm_min);
printpoint(point2);
printtime(psec, t1.tm_sec);
}
if(bioskey(1)==0) continue;
else exit(0);
}
return 0;
}
晕,还有一份字数限制了
展开全部
#include<stdio.h>
#include<reg51.h>
sbit p20=P2^0;
sbit p21=P2^1;
sbit led=P2^7;
main()
{
unsigned int dis_1[4]={0x01,0x02,0x04,0x08};
unsigned int dis_2[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned int s,m,m1,m2,h,h1,h2,i,j,k;
for(h=0;h<24;h++){
for(m=0;m<60;m++){
for(s=0;s<60;s++){
if(p20==0)h++;
if(h==24)h=0;
if(p21==0)m++;
if(m==60)m=0;
h1=h/10;
h2=h%10;
m1=m/10;
m2=m%10;
for(i=0;i<240;i++){
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[0];
P0=dis_2[h1];
}
}
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[1];
P0=dis_2[h2];
}
}
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[2];
P0=dis_2[m1];
}
}
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[3];
P0=dis_2[m2];
}
}
if(i<120)led=0;
else led=1;
}
}
}
}
}
#include<reg51.h>
sbit p20=P2^0;
sbit p21=P2^1;
sbit led=P2^7;
main()
{
unsigned int dis_1[4]={0x01,0x02,0x04,0x08};
unsigned int dis_2[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned int s,m,m1,m2,h,h1,h2,i,j,k;
for(h=0;h<24;h++){
for(m=0;m<60;m++){
for(s=0;s<60;s++){
if(p20==0)h++;
if(h==24)h=0;
if(p21==0)m++;
if(m==60)m=0;
h1=h/10;
h2=h%10;
m1=m/10;
m2=m%10;
for(i=0;i<240;i++){
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[0];
P0=dis_2[h1];
}
}
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[1];
P0=dis_2[h2];
}
}
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[2];
P0=dis_2[m1];
}
}
for(j=0;j<5;j++){
for(k=0;k<10;k++){
P1=dis_1[3];
P0=dis_2[m2];
}
}
if(i<120)led=0;
else led=1;
}
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
gotoxy他漏了头文件了,system.h,可是,好像vc++里没这头文件,turboc才有
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
弄点分用
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询