[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 4# zaqmlp

E:\DESK\输出.bat(10, 3) Microsoft JScript 编译错误: 缺少 ']'

TOP

  1. /*&cls&echo off&cd /d "%~dp0"
  2. set "length=3"
  3. set "count=100"
  4. cscript -nologo -e:jscript "%~f0" "%length%" "%count%" > "out.txt"
  5. pause
  6. exit
  7. */
  8. var len=WSH.Arguments(0).split(/[-,~]/),count=Number(WSH.Arguments(1));
  9. var charlist=[
  10.     ["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"],
  11.     ["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"],
  12.     ["0","1","2","3","4","5","6","7","8","9"]
  13. ];
  14. var r1=Number(len[0]);
  15. function getrandom(){
  16.     if(len.length==2){r1=Math.floor(Math.random()*(Number(len[1])-Number(len[0]))+Number(len[0]));}
  17.     var s=[];
  18.     for(var i=1;i<=r1;i++){
  19.         var r2=Math.floor(Math.random()*charlist.length);
  20.         var r3=Math.floor(Math.random()*charlist[r2].length);
  21.         s.push(charlist[r2][r3]);
  22.     }
  23.     return s.join("");
  24. }
  25. var dic={},n=0;
  26. for(;;){
  27.     var rs=getrandom();
  28.     if(dic[rs]==undefined){
  29.         WSH.echo(rs);
  30.         n=n+1;dic[rs]='';
  31.         if(n>=count){break;}
  32.     }
  33. }
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

本帖最后由 wanghan519 于 2023-9-6 05:30 编辑

awk写了个幂集,不知道对不对,可以存入文件a.awk再运行echo asdfg | awk -f a.awk试一下
只考虑了组合,没考虑排列。。。
  1. function powerset(x, y) {
  2.     if (length(x) > 3 || y > length($0)) {
  3.         print x
  4.         return
  5.     }
  6.     powerset(x, y + 1)
  7.     powerset(x substr($0, y, 1), y + 1)
  8. }
  9. {
  10.     powerset("", 1)
  11. }
复制代码

TOP

  1. powershell -noprofile -executionpolicy bypass "1..100|%%{((97..122),(65..90),(48..57)|%%{[char[]]$_}|Get-Random -Count 4) -join ''}" > rnd.txt
复制代码
生成100个随机字符,每行一组

TOP

返回列表