码迷,mamicode.com
首页 > 其他好文 > 详细

随机生成名字或短句代码机

时间:2015-10-06 12:46:24      阅读:505      评论:0      收藏:0      [点我收藏+]

标签:

/*
 * 随机短语生成机
 */
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);
  
  
 }
}

随机生成名字或短句代码机

标签:

原文地址:http://www.cnblogs.com/liangxiaoyu/p/4856902.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!