Apache's___Tomcat

          Java Vs .Net

          常用鏈接

          統(tǒng)計

          Blogs

          Mobile

          Program

          最新評論

          生成隨機(jī)的字符串

          2006年3月17日11:30:27

          ?1 public ? class ?ttttt? {
          ?2

          ?3 ???? private ? static ? char []?rst? = ? new ? char [ 30
          ];
          ?4

          ?5 ???? private ? static ? char []?ch? = ?
          {? ' \\ ' ,? ' ^ ' ,? ' | ' ,? ' ~ ' ,? ' ? ' ,? ' _ ' ,? ' - ' ,? ' @ ' ,
          ?6 ???????????? ' # ' ,? ' $ ' ,? ' % ' ,? ' ! ' ,? ' + ' ,? ' - ' ,? ' * ' ,? ' / ' ,? ' 0 ' ,? ' 1 ' ,? ' 2 ' ,? ' 3 ' ,? ' 4 '
          ,
          ?7 ???????????? ' 5 ' ,? ' 6 ' ,? ' 7 ' ,? ' 8 ' ,? ' 9 ' ,? ' a ' ,? ' b ' ,? ' c ' ,? ' d ' ,? ' e ' ,? ' f ' ,? ' g ' ,? ' h '
          ,
          ?8 ???????????? ' i ' ,? ' j ' ,? ' k ' ,? ' l ' ,? ' m ' ,? ' n ' ,? ' o ' ,? ' p ' ,? ' q ' ,? ' r ' ,? ' s ' ,? ' t ' ,? ' u '
          ,
          ?9 ???????????? ' v ' ,? ' w ' ,? ' x ' ,? ' y ' ,? ' z ' ,? ' A ' ,? ' B ' ,? ' C ' ,? ' D ' ,? ' E ' ,? ' F ' ,? ' G ' ,? ' H '
          ,
          10 ???????????? ' I ' ,? ' J ' ,? ' K ' ,? ' L ' ,? ' M ' ,? ' N ' ,? ' O ' ,? ' P ' ,? ' Q ' ,? ' R ' ,? ' S ' ,? ' T ' ,? ' U '
          ,
          11 ???????????? ' V ' ,? ' W ' ,? ' X ' ,? ' Y ' ,? ' Z ' ?}
          ;
          12

          13 ???? private ? static ?String?genRandomString()?
          {
          14 ???????? for ?( int ?i? = ? 0 ,?j? = ? 78 ;?i? < ? 30 ;? ++ i,? -- j)?
          {
          15 ???????????? int ?take? = ?( int )?(Math.random()? *
          ?j);
          16 ????????????rst[i]? =
          ?ch[take];
          17 ???????????? char ?m? = ?ch[j? - ? 1 ]; // ?Move?ch[take]?to?the?back?of

          18 ????????????ch[j? - ? 1 ]? = ?ch[take]; // ?ch[]
          19 ????????????ch[take]? = ?m; // ?and?then?j--
          20 ????????}

          21 ???????? return ? new ?String(rst);
          22 ????}

          23
          24 ????
          /**
          25 ?????*? @param ?args
          26 ????? */

          27 ???? public ? static ? void ?main(String[]?args)? {
          28 ???????? for ?( int ?i? = ? 0 ;?i? < ? 40 ;? ++ i)?
          {
          29
          ????????????System.out.println(genRandomString());
          30 ????????}

          31 ????}

          32 }

          posted on 2006-03-17 11:31 Apache's___Tomcat 閱讀(164) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 石泉县| 田阳县| 凯里市| 祁东县| 平舆县| 北京市| 黄浦区| 昌吉市| 舒兰市| 蕉岭县| 双流县| 高碑店市| 嵊泗县| 蛟河市| 卢氏县| 仙游县| 荔浦县| 西平县| 崇仁县| 霍邱县| 阿鲁科尔沁旗| 章丘市| 买车| 监利县| 天镇县| 大荔县| 临沂市| 西和县| 聊城市| 托克逊县| 咸丰县| 民乐县| 惠安县| 尼勒克县| 双城市| 舞阳县| 临澧县| 曲靖市| 布尔津县| 北川| 甘泉县|