zoukankan      html  css  js  c++  java
  • 16周作业

    题目一

    package com;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class thread implements Runnable{
        Date date;
        public void run() {
            while(true){
                Date date = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");
                String time = sdf.format(date);
                System.out.println(time);
                try{
                    Thread.sleep(1000);
                }catch(InterruptedException e){
                    System.out.println(e);
                }
            }
            
            
      
        }
    }
    package com;
    
    import java.util.Scanner;
    
    public class currenttime {
        
    
        public static void main(String[] args) {
            Thread t=new Thread(new thread() );
            t.start();
        }
    
    }

     题目二

    package com;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Scanner;
    public class thread implements Runnable{
        Scanner s=new Scanner(System.in);
        int flag;
        public void run() {
            while(true){
                System.out.println("请输入数字");
                int c=s.nextInt();
                int a=(int)(Math.random()*100);
                if(c>=a){
                    System.out.println("你的数字猜大了");
                }else if(c<a)
                    System.out.println("你猜的数字小了,");
                else System.out.println("恭喜你,猜对了");
             //   System.out.println(a);
                try{
                    Thread.sleep(1000);
                  
                    
                }catch(InterruptedException e){
                    System.out.println(e);
                }
           
            }
            
            
      
        }
    }
    package com;
    
    import java.util.Scanner;
    
    public class currenttime {
        
    
        public static void main(String[] args) {
            Thread t=new Thread(new thread() );
            t.start();
        }
    
    }

  • 相关阅读:
    Centos7下安装oracle 11g,弹窗不显示或者显示太小
    SQLserver登陆报错
    centos7配置网易yum源
    python ----django---打包重用
    python打包exe文件
    Acwing-198-反素数(约数, 数学)
    Acwing-197-阶乘分解(质数)
    Acwing-196-质数距离(素数区间筛法)
    Acwing-169-数独2(搜索, 剪枝)
    Acwing-168-生日蛋糕(搜索, 剪枝)
  • 原文地址:https://www.cnblogs.com/chenxiangyuu/p/12076818.html
Copyright © 2011-2022 走看看