遍历硬盘打开某个程序的批处理-高手come in

2025-03-21 09:52:41
推荐回答(4个)
回答1:

你的目的就是搜索硬盘里面你想调用的某个程序吧
下面举个例子,比如说遍历硬盘运行QQ
@echo off
for /f "delims=" %%A in ('dir /a /s /b %systemdrive%\qq.exe') do "%%A"

回答2:

所谓遍历(Traversal)是指沿着某条搜索路线,依次对树中每个结点均做一次且仅做一次访问。访问结点所做的操作依赖于具体的应用问题。
遍历是二叉树上最重要的运算之一,是二叉树上进行其它运算之基础。
遍历方案
1.遍历方案
从二叉树的递归定义可知,一棵非空的二叉树由根结点及左、右子树这三个基本部分组成。因此,在任一给定结点上,可以按某种次序执行三个操作:
1)访问结点本身(N),
2)遍历该结点的左子树(L),
3)遍历该结点的右子树(R)。
以上三种操作有六种执行次序:
NLR、LNR、LRN、NRL、RNL、RLN。
注意:
前三种次序与后三种次序对称,故只讨论先左后右的前三种次序。
2.三种遍历的命名
根据访问结点操作发生位置命名:
① NLR:前序遍历(PreorderTraversal亦称(先序遍历))
——访问结点的操作发生在遍历其左右子树之前。
② LNR:中序遍历(InorderTraversal)
——访问结点的操作发生在遍历其左右子树之中(间)。
③ LRN:后序遍历(PostorderTraversal)
——访问结点的操作发生在遍历其左右子树之后。
注意:
由于被访问的结点必是某子树的根,所以N(Node)、L(Left subtlee)和R(Right subtree)又可解释为根、根的左子树和根的右子树。NLR、LNR和LRN分别又称为先根遍历、中根遍历和后根遍历。

遍历算法

1.中序遍历的递归算法定义:
若二叉树非空,则依次执行如下操作:
(1)遍历左子树;
(2)访问根结点;
(3)遍历右子树。

2.先序遍历的递归算法定义:
若二叉树非空,则依次执行如下操作:
(1) 访问根结点;
(2) 遍历左子树;
(3) 遍历右子树。

3.后序遍历得递归算法定义:
若二叉树非空,则依次执行如下操作:
(1)遍历左子树;
(2)遍历右子树;
(3)访问根结点。

4.中序遍历的算法实现
用二叉链表做为存储结构,中序遍历算法可描述为:
void InOrder(BinTree T)
{ //算法里①~⑥是为了说明执行过程加入的标号
① if(T) { // 如果二叉树非空
② InOrder(T->lchild);
③ printf("%c",T->data); // 访问结点
④ InOrder(T->rchild);
⑤ }
⑥ } // InOrder

遍历序列

1.遍历二叉树的执行踪迹
三种递归遍历算法的搜索路线相同(如下图虚线所示)。
具体线路为:
从根结点出发,逆时针沿着二叉树外缘移动,对每个结点均途径三次,最后回到根结点。

2.遍历序列
(1) 中序序列
中序遍历二叉树时,对结点的访问次序为中序序列
【例】中序遍历上图所示的二叉树时,得到的中序序列为:
D B A E C F
(2) 先序序列
先序遍历二叉树时,对结点的访问次序为先序序列
【例】先序遍历上图所示的二叉树时,得到的先序序列为:
A B D C E F
(3) 后序序列
后序遍历二叉树时,对结点的访问次序为后序序列
【例】后序遍历上图所示的二叉树时,得到的后序序列为:
D B E F C A
注意:
(1) 在搜索路线中,若访问结点均是第一次经过结点时进行的,则是前序遍历;若访问结点均是在第二次(或第三次)经过结点时进行的,则是中序遍历(或后序遍历)。只要将搜索路线上所有在第一次、第二次和第三次经过的结点分别列表,即可分别得到该二叉树的前序序列、中序序列和后序序列。
(2) 上述三种序列都是线性序列,有且仅有一个开始结点和一个终端结点,其余结点都有且仅有一个前趋结点和一个后继结点。为了区别于树形结构中前趋(即双亲)结点和后继(即孩子)结点的概念,对上述三种线性序列,要在某结点的前趋和后继之前冠以其遍历次序名称。

(不好意思,我只知道这么多,希望对你有用。)

回答3:

SET SAFETY OFF
lspath=sys(5)+sys(2003)
nbegintime=0
nusetime=0
nendtime=0
nbegintime=SYS(2)
thisform.command2.enabled=.f.
thisform.label5.caption="正在准备搜索的目录,请稍候……"

dime dir_file(1,2)
dir_file(1,1)="(无)"
dir_file(1,2)="(无)"
dime dir_array(1,1)
*dime dir_array(1,5)
dir_array(1,1)="(无)"
thisform.list2.numberofelements=1
thisform.list1.numberofelements=1
SET EXACT ON
path=ALLTRIM(thisform.text1.value)
set default to "&path"
a=adir(lssz,"","d")
b=0
if lssz(1,1)="."
a=a-2
b=2
endif
dime dir_array(a,1)
*dime dir_array(a,5)
dir_sl=a
for c=1 to a
dir_array(c,1)=path+ALLTRIM(lssz(c+b,1))+"\"
endfor
bz=1
do while .t.
if bz=0
exit
endif
for a=1 to dir_sl
set default to "&dir_array(a,1)"
ls1=adir(lssz,"","d")
if ls1>2
dime dir_array(dir_sl+ls1-2,1) &&dime dir_array(dir_sl+ls1-2,5)
for c=3 to ls1
dir_array(dir_sl+c-2,1)=dir_array(a,1)+lssz(c,1)+"\"
endfo
dir_sl=dir_sl+ls1-2
bz=1
else
bz=0
endif
endfor
enddo
dir_sl=dir_sl+1
dime dir_array(dir_sl,1) &&dime dir_array(dir_sl,5)
dir_array(dir_sl,1)=path
*asort(dir_array)
SET EXACT ON
set default to "&lspath"
CREATE TABLE 临时A (目录名 C(200))
sele 临时A
append from array dir_array
SORT TO 临时B ON 目录名
USE 临时B
SORT TO 临时c ON 目录名 &&
total to 临时A on 目录名
use 临时A
thisform.list1.numberofelements=alen(dir_array,1)
count to a
dime dir_array(a,1) &&dime dir_array(a,5)
copy to array dir_array
use
dir_sl=a
thisform.label1.caption="共找到"+str(dir_sl,6)+" 个文件夹"
thisform.list1.numberofelements=alen(dir_array,1)
SELECT 电子文档
IF thisform.Optiongroup2.Value=1
ZAP
ENDIF
a=0
for b=1 to dir_sl
d=1
do while .t.
set default to "&dir_array(b,1)"
thisform.label5.caption="正在搜索的目录:"+dir_array(b,1)
thisform.label6.caption="正在搜索的文件:"+alltrim(thisform.text2.value)
thisform.label7.caption="已搜索的目录数:"+str(b,4)
if d=1
c=sys(2000,alltrim(thisform.text2.value))
else
c=sys(2000,alltrim(thisform.text2.value),1)
endif
thisform.label8.caption="搜索到的文件名:"+c
thisform.label4.caption="共找到"+str(a,6)+" 个文件"
if c==""
exit
endif
a=a+1
d=2
dime dir_file(a,2)
dir_file(a,1)=c
dir_file(a,2)=ALLTRIM(dir_array(b,1))
thisform.list2.numberofelements=alen(dir_file,1)
SELECT 电子文档
append blank
REPLACE 名称 with ALLTRIM(c),路径 WITH ALLTRIM(dir_array(b,1))
*thisform.Grd电子文档.Refresh
enddo
ENDFOR
thisform.Grd电子文档.Refresh

set default to "&lspath"
DELETE FILE 临时A.DBF
DELETE FILE 临时B.DBF
DELETE FILE 临时C.DBF

thisform.label5.caption=""
thisform.label6.caption=""
thisform.label7.caption=""
thisform.label8.caption=""
thisform.command2.enabled=.t.
nendtime=SYS(2)
nusetime=VAL(nendtime)-VAL(nbegintime)
thisform.label5.caption="本次处理花费时间: "+ALLTRIM(STR(nusetime,10))+' 秒。'

回答4:

这个我真的不会.

我是来给楼主加油的.

问题总有解决的办法.招急是没用的.

加油吧