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

答题

1.
  1. @echo off
  2. for /l %%i in (1,1,100) do echo %%i
  3. pause>nul
复制代码
2.
  1. @echo off
  2. for /l %%i in (1,1,50) do set /a b=%%i+%%i-1&call echo %%b%%
  3. pause>nul
复制代码
3.
  1. @echo off
  2. for /l %%i in (1,1,50) do set /a b=%%i+%%i-1&call echo %%b%%
  3. pause>nul
复制代码
4.
一、
  1. @echo off
  2. for /f "tokens=*" %%i in (f:\test.txt) do echo %%i
  3. pause>nul
复制代码
二、
  1. @echo off
  2. for /f "tokens=2" %%i in (f:\test.txt) do echo %%i
  3. pause>nul
复制代码

[ 本帖最后由 nopr 于 2009-8-2 16:38 编辑 ]

TOP

回复 2楼 的帖子

@echo off
for /f "tokens=1-3" %%i in (b.txt) do (
echo %%i
echo %%j
echo %%k
)
pause
一个也可以啊!

TOP

第四题 我想应该是这样吧

  1. @echo off
  2. for /f "tokens=2" %%i in (test.txt) do echo %%i
  3. pause>nul
复制代码

TOP

3

@echo off
for %%i in (bbs bathome.net) do echo %%i
pause

TOP

批处理运行窗口显示 1、3、5.....99这50个数字

@echo off
for /L %%i in (1,2,100) do echo %%i
pause

TOP

批处理运行窗口显示1~100 这100 个数字

@echo off
for /L %%i in (1,1,100) do echo %%i
pause

TOP

回帖

@echo off
set /p go=goto:
goto 2>nul %go% || echo error~ && pause
:1
for /l %%i in (1,1,100) do (
echo %%i
)
pause
goto :eof

:2
for /l %%i in (1,2,99) do (
echo %%i
)
pause
goto :eof

:3
set x=bbs bathome.net
for %%i in (%x%) do (
echo %%i
)
pause
goto :eof

:4
for /f "delims=" %%i in (test.txt) do (
echo %%i
)
pause
goto :eof

:5
for /f "tokens=2" %%i in (test.txt) do (
echo %%i
)
pause
exit

TOP

@echo off
for /l %%a in (1,1,100) do echo %%a
pause

for /l %%b in (1,2,100) do echo %%b
pause


set var=bbs bathome.net
echo %var%
for  %%a in (%var%) do echo %%a
pause

TOP

更正

不好意思,我上帖中第4题,有点写错了,我的机子没有F盘,就在C盘调试了,与原题不符
应该把
for /f "tokens=2" %%i in (C:\test.txt) do echo %%i
改成
for /f "tokens=2" %%i in (F:\test.txt) do echo %%i

TOP

标准答案

1:
@echo off
for /l %%i in (1,1,100) do echo %%i
pause>nul
2:
@echo off
for /l %%i in (1,2,99) do echo %%i
pause>nul
3:
@echo off
for %%i in (bbs bathome.net) do echo %%i
pause>nul
4:
@echo off
for /f "tokens=2" %%i in (C:\test.txt) do echo %%i
pause>nul

TOP

第四题

@echo off
find "1"  test.txt >a.txt
find "4" test.txt >b.txt
find "7" test.txt >c.txt
for /f  "skip=2 tokens=2" %%a in (a.txt) do echo %%a
for /f "skip=2 tokens=2" %%b in (b.txt) do echo %%b
for /f "skip=2 tokens=2" %%c in (c.txt) do echo %%c

pause>nul

TOP

回复 119楼 的帖子

本来就是基础题,让新手们,熟悉for语句的基本用法。
(*^_^*)

TOP

3、将 bbs bathome.net (在同一行)分成三行显示在批处理运行窗口;
这个问题比较简单吧

TOP

感慨!

1      2        3
4      5        6
7      8        9

TOP

回复 116楼 的帖子

请先在本论坛的 批处理教学&资料 版块,多多潜水!
(*^_^*)

TOP

返回列表