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