
对硬件的啊。
P2=0;
P1=display_code[display_data[i]];
P2=k;
k=k>>1;
不懂。
不过感觉问题不大。先把main里的i的上限从250改到216
在display()里做3个判断(可能会要做个全局变量,或者加个参数,记录当前是多少。)
判断是否是0,大于10,大于100
另外,站长团上有产品团购,便宜有保证
#include <stdioh>
#include <windowsh>
int main()
{
int min, sec, sum;
int i;
sum = 0;
printf("请输入分数和秒数: ");
scanf("%d, %d", &min, &sec);
getchar();
sum = min60+sec;
printf("你将等待%ds\n", sum);
for(i=0; i<sum; i++)
{
printf("\r还剩%ds", sum-i);
Sleep(1000);
}
return 0;
}
Dim Ts As Integer, Tm As Integer, Th As Integer
Dim StartT As Boolean
Private Sub Command1_Click()
If StartT = False Then
Command1Caption = "暂停时间"
Else
Command1Caption = "启动时间"
End If
StartT = Not StartT
End Sub
Private Sub Command2_Click()
StartT = False
Command1Caption = "启动时间"
Ts = 0
Tm = 0
Th = 0
End Sub
Private Sub Command3_Click()
Th = Val(InputBox("输入小时"))
Tm = Val(InputBox("输入分钟"))
Ts = Val(InputBox("输入秒"))
End Sub
Private Sub Form_Load()
Command1Caption = "启动时间"
Command2Caption = "停止"
Command3Caption = "设置时间"
Label1Caption = "0:00:00"
Timer1Enabled = True
Timer1Interval = 1000
Ts = 0
Tm = 0
Th = 0
StartT = False
End Sub
Private Sub Timer1_Timer()
If StartT = True Then
Ts = Ts - 1
If Ts = -1 Then
Ts = 59
Tm = Tm - 1
If Tm = -1 Then
Tm = 59
Th = Th - 1
End If
End If
If Th = 0 And Tm = 0 And Ts = 0 Then
StartT = False
End If
End If
Label1Caption = Th & ":" & Format(Tm, "00") & ":" & Format(Ts, "00")
End Sub
程序的窗体内含有两个Timer控件,一个文本框控件,两个命令按钮控件,四个标签控件。其中Timer1的Interval属性设置为60000,也就是一分钟响应一次,Timer1的Interval属性设置为500,也就是每05秒响应一次。Label1显示剩余时间,Label2显示现在时间。
代码如下:
Dim n As Integer
Dim t As String
Private Sub Command1_Click() '计时开始
If Text1Text = "" Then
Exit Sub
End If
t = Val(Text1Text)
Timer1Enabled = True
Label1Caption = "剩余时间:" & t & "分钟"
End Sub
Private Sub Command2_Click() '退出程序
End
End Sub
Private Sub Timer1_Timer()
n = n + 1
Label1Caption = "剩余时间:" & t - n & "分钟"
If n = t Then
Beep
MsgBox "时间到", vbExclamation + vbOKOnly
Timer1Enabled = False
n = 0
End If
End Sub
Private Sub Timer2_Timer()
Label2Caption = "现在时间:" & Time
End Sub
如果你有TC,可以试一试。
VC 的 kbhit() 不能返回 键名。
23:59:59 -- 86400 秒
#include <stdioh>
#include <windowsh>
#include <conioh>
void main()
{
long int t;
int flag =0;
t = 86400;
printf("press S start, press E stop\n");
while(1)
{
if (kbhit() == 'S' || kbhit() == 's') flag =1;
if (kbhit() == 'E' || kbhit() == 'e') flag =0;
Sleep(1000);
if (flag == 1) t = t -1;
if (t <= 0) break;
printf("%d ",t);
}
以上就是关于c语言 倒计时程序全部的内容,包括:c语言 倒计时程序、c语言倒计时程序设计:要求从键盘输入倒计的时间分数和秒数,按“回车键”开始倒计,直到计时时间结束。、设计一个倒计时的程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)