随机生成名字或短句代码机
2015-10-06 11:41
225 查看
/*
* 随机短语生成机
*/
public class Pharse {
public static void main(String[] args) {
//可随意添加字符
String[] wordListOne = {
"三","组","的","我","哦","热","耳","低","安"
};
String[] wordListThree = {
"三","不","看","飞","\\(^o^)/~","第","耳","低","随"
};
String[] wordListTwo = {
"狗","组","看","飞","哦","第","是","低","速"
};
//计算每一组有多少个术语
int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length ;
//产生随机数字
int rand1 = (int)(Math.random()*oneLength);
int rand2 = (int)(Math.random()*twoLength);
int rand3 = (int)(Math.random()*threeLength);
//组合出术语
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " +wordListThree[rand3];
//输出
System.out.println(phrase);
}
}
* 随机短语生成机
*/
public class Pharse {
public static void main(String[] args) {
//可随意添加字符
String[] wordListOne = {
"三","组","的","我","哦","热","耳","低","安"
};
String[] wordListThree = {
"三","不","看","飞","\\(^o^)/~","第","耳","低","随"
};
String[] wordListTwo = {
"狗","组","看","飞","哦","第","是","低","速"
};
//计算每一组有多少个术语
int oneLength = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length ;
//产生随机数字
int rand1 = (int)(Math.random()*oneLength);
int rand2 = (int)(Math.random()*twoLength);
int rand3 = (int)(Math.random()*threeLength);
//组合出术语
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " +wordListThree[rand3];
//输出
System.out.println(phrase);
}
}
相关文章推荐
- thinkphp-关于模板里 IP 地址的引用实例
- [Python进阶-6]错误异常处理,断言assert,日志logging,单元测试,文档测试
- 《编程之美》小飞的电梯调度算法
- C语言-九宫格
- PhoneGap 上传图片HTML和服务器端端实现(JAVA)
- C++模板函数
- PHP数据类型转换(字符转数字,数字转字符)
- 2.Python补充_Python小技巧
- 《机器学习实战》笔记之九——树回归
- Java多线程18:线程池
- Eclipse web 项目转到myEclipse无法导出WAR包
- (日志,《算法导论》.7)快速排序,代码
- java自带线程池和队列详细讲解
- c++ for_each
- thinkphp学习笔记1
- ubuntu下C,C++,opencv cuda编程
- C++ const关键字
- java拾遗之关键字static
- java中的构造器
- Asp.net 解析json