3

简单验证码生成程序

通过数组存储26个大写字母和26个小写字母和0-9数字

随机成0-61的4个数字对应数组下标

输出四位验证码。

package 验证码程序;

import java.util.Random;

public class Number {

public String []array= {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S",
"T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t",
"u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"};
public int a,b,c,d;
public String creat() {
Random rand =new Random();
a=rand.nextInt(61) + 0;
b=rand.nextInt(61) + 0;
c=rand.nextInt(61) + 0;
d=rand.nextInt(61) + 0;
String e = array[a]+" "+array[b]+" "+array[c]+" "+array[d];
//System.out.println("验证码:");
//System.out.println(array[a]+" "+array[b]+" "+array[c]+" "+array[d]);
return e;
}
}

上一篇:[算法笔记]模拟退火


下一篇:时间复杂度和空间复杂度