如何用java生成有规律的字符串?

来源:百度知道 编辑:UC知道 时间:2024/06/30 17:55:53
用java生成有规律的字符串

1、生成6位的字符串,范围:26个字母a~z和10个数字0~9。
2、其中前三位是小写字母,后三位是数字。
3、前三位字符字母不能出现重码,如:aaa或aa等字样。
4、后三位数字,要生成:012或234连号形式。
5、最后生成的字符串会是如:whk012,asd123等形式。
6、请高手帮忙。

如果可能的话,生成txt文件,且每个文件不大于100K。
我是初级学习者,麻烦有心人帮忙写一下.谢谢.或写个大概都行.

import java.io.*;
public class Test{
static long k=0;
static char[] c=new char[3];
static boolean[] b=new boolean[26];
static void create(char[] word,String[] num,BufferedWriter bw,int i)throws Exception{
if(i==3){
for(int k=0;k<num.length;k++)
bw.write(""+c[0]+c[1]+c[2]+num[k]+" ");
bw.write("\r\n");
return;
}
for(int j=0;j<word.length;j++){
if(b[j]==true)
continue;
b[j]=true;
c[i]=word[j];
create(word,num,bw,i+1);
b[j]=false;
}
}
public static void main(String[] args)throws Exception{
BufferedWriter bw=new BufferedWriter(new FileWriter("String.txt"));
char[] word=new char[26];
for(int i=0;i<26;i++)
word[i]=(char)(i+97);
String[] num={"012","123","234","345","456","567","678&quo