zoukankan      html  css  js  c++  java
  • 16

    题目1

    package com;
    
    import java.awt.Graphics;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class thread implements Runnable{
        Thread clockThread;
        Date date;
        public void start() {
            if(clockThread==null){
                clockThread=new Thread(); 
                clockThread.start();
        }
            }
        
        public void run() {
            while(clockThread!=null){
                Date date = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");
                String time = sdf.format(date);
                System.out.println(time);        
            }
            try{
                clockThread.sleep(1000);
            }catch(InterruptedException e){
                System.out.println(e);
            }
        }
    }


    package com;
    
    public class currenttime {
        
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            thread t=new thread();
            t.start();
            t.run();
        }
    
    }

     题目二

    package com;
    
    import java.awt.Graphics;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Scanner;
    public class thread implements Runnable{
        Thread clockThread;
        public void start() {
            if(clockThread==null){
                clockThread=new Thread(); 
                clockThread.start();
        }
            }
        
        public void run() {
            Scanner s=new Scanner(System.in);
            System.out.println("input");
            int c=s.nextInt();
            int ran=((int)Math.random()*100);
            
            
                if(c>ran){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
        
            
            try{
                clockThread.sleep(4000000);
            }catch(InterruptedException e){
                System.out.println(e);
            }
        }
    }

  • 相关阅读:
    [模板]杜教筛
    [NOIP2014]解方程
    [NOIP2016] 组合数问题
    [HAOI2011] Problem b
    Rmq Problem mex
    [模板]Link-Cut-Tree
    [SDOI2013]森林
    单调队列优化多重背包
    [USACO17JAN]Promotion Counting
    [模板] 点分治
  • 原文地址:https://www.cnblogs.com/chenxiangyuu/p/12060870.html
Copyright © 2011-2022 走看看