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

    import java.util.Random;

    import java.util.Scanner;

    public class RandomStr {

    public static void main (String []args){

           int length=6;

           System.out.println("请选择六位验证码中数字的位数:");

           Scanner scanner=new Scanner(System.in);

           int a=scanner.nextInt();

           if(a>6)

           {

                  for(;a>6;)

                  {

                         System.out.println("输入错误,请再次输入六以内的正整数:");

                         Scanner scannerc=new Scanner(System.in);

                         int c=scannerc.nextInt();

                         a=c;

                  }

           }

          

           int b=length-a;

           if(b>0){

           System.out.println("则字母的位数为:"+b);

           System.out.println("请选择字母的大小写(大写选1     小写选2)");

           Scanner scannerz=new Scanner(System.in);

           int d=scannerz.nextInt();

           if(d>2||d<0)

           {

                  for(;d>2||d<0;)

                  {

                         System.out.println("输入错误,请按要求再次选择选择:");

                         System.out.println("大写选1     小写选2");

                         Scanner scannerc=new Scanner(System.in);

                         int c=scannerc.nextInt();

                         d=c;

                  }

           }

          

           if(d==1){

                  int x[]=new int[a];

                  int Y[]=new int[b];

                  char Y1[]=new char[b];

                  System.out.print("生成的验证码为:");

                  //验证码

                 

                  //数字的输入与输出

                  for(int i=0;i<a;i++){

                  x[i]=(int)(1+Math.random()*(9-1+1));

                  }

                  for(int i=0;i<a;i++){

                  System.out.print(""+x[i]);

                  }     

                 

                  //大写字母的输入与输出

                  for(int j=0;j<b;j++){

                  Y[j]=(int)(65+Math.random()*(90-65+1));

                  Y1[j]=(char)Y[j];

                  System.out.print(""+Y1[j]);

                  }

           }

           else if(d==2){

                  int x[]=new int[a];

                  int Y[]=new int[b];

                  char Y1[]=new char[b];

                  System.out.print("生成的验证码为:");

                  //验证码

                 

                  //数字的输入与输出

                  for(int i=0;i<a;i++){

                  x[i]=(int)(1+Math.random()*(9-1+1));

                  }

                  for(int i=0;i<a;i++){

                  System.out.print(""+x[i]);

                  }     

                 

                  //小写字母的输入与输出

                  for(int j=0;j<b;j++){

                  Y[j]=(int)(97+Math.random()*(122-97+1));

                  Y1[j]=(char)Y[j];

                  System.out.print(""+Y1[j]);

                  }

           }

           }

           else if (b<=0){

           System.out.print("生成的验证码为:");

           int x=(int)(1+Math.random()*(999999-1+1));

           System.out.println(""+x);

           }

          

          

    }

    }

     

     

    是多疑还是去相信 谎言背后的忠心 或许是自己太执迷 命题游戏 沿着他的脚步 呼吸开始变得急促 就算看清了面目 设下埋伏 真相却居无定处 I swear I'll never be with the devil 用尽一生孤独 没有退路的路 你看不到我 眉眼焦灼却不明下落 命运的轮轴 伺机而动 来不及闪躲 沿着他的脚步 呼吸开始变得急促 就算看清了面目 设下埋伏 真相却居无定处 I swear I'll never be with the devil 用尽一生孤独 没有退路的路 你看不到我 眉眼焦灼却不明下落 命运的轮轴 伺机而动 来不及闪躲 你看不到我 眉眼焦灼却不明下落 命运的轮轴 伺机而动 来不及闪躲 黑夜和白昼 你争我夺 真相被蛊惑 心从不退缩 这天堂荒漠 留给孤独的猎手
  • 相关阅读:
    MOF编译器无法连接VMI服务器。原因可能是语义错误的解决方案
    【原】Sql Server 2008---安装时卸载Visual Studio
    SQL SERVER 删除前判断指定的表或者存储过程是否存在
    NPOI 表头、页眉页脚重复设置
    在vs2010中显示代码的行数
    【summary】JQuery 相关css、ajax、数据操作函数或方法
    CSS自适应的占位符效果
    NPOI 生成 excel基本设置
    JavaSE——转换流和缓冲流
    javaSE——字符流
  • 原文地址:https://www.cnblogs.com/muailiulan/p/9745239.html
Copyright © 2011-2022 走看看