3 回答
TA贡献1780条经验 获得超5个赞
<
p
></
p
>
<
input
type
=
"button"
value
=
"提交"
onclick
=
"test()"
>
<
script
>
var count = 1800;
var p = document.querySelector('p')
var intervalId = window.setInterval(countDown, 1000)
function countDown() {
--count
p.innerText = timeFormat()
}
function test() {
count += 60 * 60
p.innerText = timeFormat()
}
var hour, minute, second
var timeText;
function timeFormat() {
hour = Math.floor(count / (60 * 60));
minute = Math.floor(count / 60) - (hour * 60);
second = Math.floor(count) - (hour * 60 * 60) - (minute * 60);
timeText = hour + ':' + minute + ':' + second
return timeText
}
</
script
>
TA贡献1886条经验 获得超2个赞
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
void my_menu(void)
{
system("cls");
printf("界面\n");
}
void my_operate(void)
{
printf("%c\n", getch());//注意:可以将输入值用数组等保存,这里没有保存
}
void my_time(void)
{
int i;
for (i=60; i>0; i--)
{
Sleep(999);
system("cls");
printf("倒计时:%d\n", i);
printf("\n请输入一个字符:");
if (kbhit())
{
my_operate();
}
}
my_menu();
}
int main(void)
{
my_time();
return 0;
}
- 3 回答
- 0 关注
- 996 浏览
添加回答
举报