zoukankan      html  css  js  c++  java
  • 1.14验证码 *

    package lianxi;
    
    import java.util.*;
    
    public class lianxi114 {
    
        public static void main(String[] args) {
            // 验证码
            String str = "ab1c1defg2hijkl4mno6pq7r8st9u3vwsyz";
            System.out.print("请输入验证码:");
            for (int i = 0; i < 4; i++) {
                Random ran = new Random();
                int ran1 = ran.nextInt(str.length() - 1);
                System.out.print(str.substring(ran1, ran1 + 1));
            }
            System.out.println();
    }
    }
    package lianxi;
    
    import java.util.Random;
    import java.util.Scanner;
    
    public class caipiao {
    
        public static void main(String[] args) {
            // TODO 自动生成的方法存根
            System.out.println("请输入你需要机选的注数");
            int count = new Scanner(System.in).nextInt();
            for (int i = 1; i <= count; i++) {
                realize();
            }
        }
    
        public static void realize() {
            int red = 33;
            int blue = 16;
            int numLength = 7;
            int[] random = new int[numLength];
            outer: for (int i = 0; i < numLength - 1; i++) {
                int count = 0;
                int redNum = new Random().nextInt(red + 1);
                for (int j = 0; j < numLength - 1; j++) {
                    if (redNum != random[j] && redNum != 0) {
                        count++;
                        if (count == numLength - 1) {
                            random[i] = redNum;
                            break;
                        } else {
                            continue;
                        }
                    } else {
                        i--;
                        continue outer;
                    }
                }
            }
            outer1: for (int i = numLength - 1; i < numLength; i++) {
                int blueNum = new Random().nextInt(blue + 1);
                for (int j = numLength - 1; j < numLength; j++) {
                    if (blueNum != random[j]) {
                        random[i] = blueNum;
                        break;
                    } else {
                        i--;
                        continue outer1;
                    }
                }
            }
            for (int i = 0; i < numLength; i++) {
                if (i > 0 && i < numLength - 1) {
                    if (i != numLength - 2) {
                        if (random[i] < 10) {
                            System.out.print("0" + random[i] + ",");
                        } else {
                            System.out.print(random[i] + ",");
                        }
                    } else {
                        if (random[i] < 10) {
                            System.out.print("0" + random[i]);
                        } else {
                            System.out.print(random[i]);
                        }
                    }
                } else {
                    if (i != 0) {
                        if (random[i] < 10) {
                            System.out.println("蓝球:" + "0" + random[i]);
                        } else {
                            System.out.println("蓝球:" + random[i]);
                        }
                    } else {
                        if (random[i] < 10) {
                            System.out.print("红球:" + "0" + random[i] + ",");
                        } else {
                            System.out.print("红球:" + random[i] + ",");
                        }
                    }
                }
            }
        }
    
    }

  • 相关阅读:
    【GPS】Android O平台如何设置SUPL地址,以及GPS三个配置文件的优先级分析
    【GPS】gps.conf文件解读
    【GPS】SAP测试GPS模块拿不到sensor数据
    Linux系统安装Samba共享服务器详解及安装配置
    CentOS 6.5 编译安装 LNMP环境
    linux禁止root用户直接登录
    Linux下安装配置日志服务器
    Windows系统安装Oracle 11g客户端
    Linux系统zabbix_agentd客户端安装与配置
    Redhat6.5——解决yum功能不能正常使用
  • 原文地址:https://www.cnblogs.com/zhanghaozhe8462/p/5132229.html
Copyright © 2011-2022 走看看