批处理生成随机数字(共三个,悬赏百度最高限额250)
发布网友
发布时间:2022-05-24 07:44
我来回答
共6个回答
热心网友
时间:2023-10-08 23:16
@echo off& setlocal enabledelayedexpansion
mode con cols=60 lines=10& color 0a& title .
del smile.txt 2>nul& echo.1.纯数字 2.数字英文 3.数字英文符号
set /p wind=选择序号:& echo. & set /p snow=输入生成组合个数:
for %%1 in (0 1 2 3 4 5 6 7 8 9 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 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)do (set /a x+=1&& set x!x!=%%1)
if "%wind%"=="1" (for /l %%1 in (1 1 %snow%)do (for /l %%2 in (1 1 10)do (set /a n%%2=!random! %% 10
set m%%1=!m%%1!!n%%2!)
cls& echo %%1/%snow%& echo !m%%1!>>smile.txt))
if "%wind%"=="2" (for /l %%1 in (1 1 %snow%)do (for /l %%2 in (1 1 10)do (set /a n%%2=!random! %% 62 +1
call set m%%1=!m%%1!%%x!n%%2!%%)
cls& echo %%1/%snow%& echo !m%%1!>>smile.txt))
if "%wind%"=="3" (more +14 "%~F0">smile.vbs& smile.vbs %snow%&& del smile.vbs)
if exist smile.txt (start "" "smile.txt")else mshta vbscript:msgbox("输入错误")(close)
exit
x=array("0","1","2","3","4","5","6","7","8","9","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","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","~","!","@","#","$","%","^","&","*","(",")","_","+","|","[","]","{","}",";","'",":",",",".","/","<",">","?")
for i = 1 to wscript.arguments(0)
for j = 1 to 10
Randomize
y=int(1000000*rnd mod 89)
n=n & x(y): next
n=n & vbcrlf: next
createobject("scripting.filesystemobject").opentextfile("smile.txt",2,true).writeline n
热心网友
时间:2023-10-08 23:16
非要批处理?Python行不行?PHP行不行?Excel行不行?VBS行不行?JS行不行?追问只要批处理,其他的不要,谢谢
热心网友
时间:2023-10-08 23:17
public class Test
{
//用于存放输出的字符
private static List contact = new ArrayList();
//输出字符个数
private static int num = 10;
private static Random random = new Random();
private static String path = "c:/out.txt";
/**
* 将要打印的字符放入contact中
*/
public static void init()
{
contact.add(0);
contact.add(1);
contact.add(2);
contact.add(3);
contact.add(4);
contact.add(5);
contact.add(6);
contact.add(7);
contact.add(8);
contact.add(9);
}
public static void main(String[] args) {
//初始化
init();
int j = 0;
String str = "";
for(int i = 0; i < num; i++)
{
j = random.nextInt(contact.size());
str += contact.get(j);
}
BufferedWriter bufferedWriter = null;
try
{
bufferedWriter = new BufferedWriter(new FileWriter(new File(path)));
bufferedWriter.write(str);
bufferedWriter.flush();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(null != bufferedWriter)
{
try
{
bufferedWriter.close();
bufferedWriter = null;
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
这是第一题,其他几题只需要将init方法中加入其他字符就可以了追问辛苦了,不过我需要的是批处理,谢谢
热心网友
时间:2023-10-08 23:17
第一条容易实现,我来吧:
@echo off
set i=1
:start
set /a i=%i%+1
set var=%random%%random%%random%%random%%random%%random%%random%
echo %var:~0,10% >>2.txt
if %i% LSS 100 goto start
echo 文件创建成功,按任意键打开查看...
pause
start 2.txt
exit
热心网友
时间:2023-10-08 23:18
密码字典可以生成你的数据,但不是批处理
施主何必如此执着??
热心网友
时间:2023-10-08 23:19
一刻舍尔可以的