• 上机作业5.28


    package yidong;
    
    import java.util.Random;
    
    public class Text {
    
    	public static void main(String[] args) {
    		int a[] = new int[10];
    		Random r = new Random();
    		for (int i = 0; i < a.length; i++) {
    			a[i] = r.nextInt(100);
    		}
    		for (int i = 0; i < a.length; i++) {
    			System.out.println(a[i]);
    		}
    	}
    
    }
    

      

    package yidong;
    
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    public class Text {
    	public static void main(String[] args) {
    		Date c = new Date();
    		SimpleDateFormat a1 = new SimpleDateFormat("Eyyyy年MM月dd日");
    		SimpleDateFormat a2 = new SimpleDateFormat("今天是Eyyyy年的第 D 天 ,E");
    		System.out.println(a1.format(c));
    		System.out.println(a2.format(c));
    
    	}
    }
    

      

    package yidong;
    import java.util.Scanner;
    public class Text {
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            System.out.print("请输入合法的邮箱:");
            String s = input.nextLine();
            int a = 0;
            int b = 0;
            int x = 0;
            int y = 0;
            for (int i= 0; i < s.length() - 1; i++) {
                String str = s.substring(i, i + 1);
                if (str.equals("@")) {
                    a++;
                    x = i;
                }
                if (str.equals(".")) {
                   b++;
                    y = i;
                }
            }
            if (a == 1 &&b == 1 && x < (y - 1) && x != 0 && y != s.length() - 1) {
               s.endsWith("@qq.com");
                System.out.println("合法");
            } else {
                System.out.println("不合法");
            }
            String s1 = s.substring(0, s.indexOf("@"));
    		System.out.println("用户名是:"+s1);
        }
    }
    

      

  • 相关阅读:
    C#获取屏幕鼠标所指点的颜色
    C#连接SQLServer数据库基本实现
    论文摘要写法
    红黑树
    递归、迭代和分治法
    逻辑右/左移与算术右/左移
    C 中数字数据类型在不同机器上所占字节数
    十进制转十六进制
    c带头结点的单链表逆置
    求一维数组长度误区
  • 原文地址:https://www.cnblogs.com/hzpiou/p/12979207.html
Copyright © 2020-2023  润新知