谢谢,你完全回答了我的第一个问题,我确实需要使用findstr / f / c:而不是findstr / c:。
因为我提出的问题已经得到解答,我觉得这个话题已经解决,“滴答”当之无愧:P我已经转到另一个帖子来帮助解决我遇到的新问题。
@echo off
echo --------------------
echo Lottery Program
echo --------------------
echo.
echo.
echo These are the Taken numbers.
type takennumbersnice.txt
echo.
echo.
set /p name= Please type the players name
:thestart
echo ---------------------------
set /p multinum1= Please type their first number [01-100]
findstr /x /c:%multinum1% takennumbersnice.txt && (
echo This number has already been taken! & pause && goto thestart
) || (
echo %multinum1%>> takennumbers.txt & goto next)
:next
:thestart2
echo ---------------------------
set /p multinum2= Now type their second number [0 if they only picked 1 number]
if '%multinum2%'=='0' (
goto endofnums
) else (
goto 3
)
:3
findstr /x /c:%multinum2% takennumbersnice.txt && (
echo This number has already been taken! & pause && goto thestart2
) || (
echo %multinum2%>> takennumbers.txt &goto next2)
:next2
:thestart3
echo ---------------------------
set /p multinum3= Now type their third number [0 if they only picked 2 numbers]
if '%multinum3%'=='0' (
goto endofnums
) else (
goto 4
)
:4
findstr /x /c:%multinum3% takennumbersnice.txt && (
echo This number has already been taken! & pause && goto thestart3
) || (
echo %multinum3%>> takennumbers.txt &goto next3)
:next3
:thestart4
echo ---------------------------
set /p multinum4= Now type their fourth number [0 if they only picked 3 numbers]
if '%multinum4%'=='0' (
goto endofnums
) else (
goto 5
)
:5
findstr /x /c:%multinum4% takennumbersnice.txt && (
echo This number has already been taken! & pause && goto thestart4
) || (
echo %multinum4%>> takennumbers.txt &goto next4)
:next4
:thestart5
echo ---------------------------
set /p multinum5= Now type their fifth number [0 if they only picked 4 numbers]
if '%multinum5%'=='0' (
goto endofnums
) else (
goto 6
)
:6
echo ---------------------------
findstr /x /c:%multinum5% takennumbersnice.txt && (
echo This number has already been taken! & pause && goto thestart5
) || (
echo %multinum5%>> takennumbers.txt)
:endofnums
set number= %multinum1% %multinum2% %multinum3% %multinum4% %multinum5%
echo %name% has chosen the number[s] %number%
echo %name% %number% >> lottery.txt
sort < takennumbers.txt > takennumbersnice.txt
echo press any key to exit
pause > nul
exit
答案 0 :(得分:0)
如果省略/ X-Switch for findstr(完全匹配), findstr将在“ 10 0”和“ 10 00”中找到“a” 10 “。
尝试findstr /x /c:
(...)