当前位置:首页 > 代码 > 正文

简单倒计时代码(web倒计时代码)

admin 发布:2022-12-19 22:58 130


今天给各位分享简单倒计时代码的知识,其中也会对web倒计时代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

倒计时代码怎么写?

#python 倒计时代码

import time

count = 0

min = 10 #倒计时10个数

while (count min):

time.sleep(1)#倒计时休眠时间1秒。

print("\r%s" % str(min - count).center(20,'-'), end="") # 总长度20,字符居中,其余部分用'-'填空

count += 1

写一个倒计时的代码!要简洁!大虾们帮忙啦

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

public class TestTime extends Thread implements ActionListener{

private int t=7200;

JLabel label=new JLabel(" 2:00:00 ");

@Override

public void actionPerformed(ActionEvent e) {

// String comm=e.getActionCommand();

// if("倒计时".equals(comm)){

this.start();

// }

}

public void run(){

while(true){

label.setText(cal());

try {

Thread.sleep(1000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if(t==0)

System.exit(0);

}

}

public String cal(){

int h=t/3600;

int m=t%3600/60;

int s=t%60;

t=t-1;

return h+":"+m+":"+s;

}

public TestTime(){

JFrame frame=new JFrame("倒计时");

frame.setLayout(new FlowLayout());

JButton button=new JButton("倒计时");

frame.add(label);

frame.add(button);

button.addActionListener(this);//此处只有你注册监听了的

frame.setLocation(200,100);

frame.setSize(200,300);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args) {

new TestTime();

}

}

求个c语言小代码,很简单的分钟倒计时程序

//有很多种方法,我这里用的是其中一种:

#include stdio.h

#include Windows.h

int main(void) {

 int minutes;

 printf("请输入分钟数:\n");

 scanf("minutes");

 for (; minutes = 0; --minutes) {

  for (int i = 60; i = 0; --i) {

    printf("还剩 %d 分钟 %d 秒 结束\n", minutes, i);//输出剩余时间

    Sleep(1000);//延时函数延时一秒

   };

 };

 printf("计时结束\n");

 system("PAUSE");

 return 0;

};

//我没上编译器测试,但是具体架构就是这样

关于简单倒计时代码和web倒计时代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/28914.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载