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();
        }
    
    }

  • 相关阅读:
    unzip详解,Linux系统如何解压缩zip文件?
    什么是FHS,Linux的文件系统目录标准是怎样的
    第三篇:Linux的基本操作与文件管理(纯命令行模式下)(上)
    什么是YUM
    KineticJS教程(12)
    KineticJS教程(11)
    KineticJS教程(10)
    KineticJS教程(9)
    KineticJS教程(8)
    KineticJS教程(7)
  • 原文地址:https://www.cnblogs.com/chenxiangyuu/p/12076818.html
Copyright © 2011-2022 走看看