全球旧事资料 分类
533算法:EX5_33输入:已排序的数组A1…
,整数x输出:如果A中存在两个数,它们的和是x,则输出这两个数,若不存在,则输出
o
efi
d1
e
dEX5_33过程:fi
dst确定As…t中是否存在两个数,它们的和是x,如果存在则输出这两个数,若不存在,则输出
o
eifstthe
output
o
eelseifstthe
ifAsAtxthe
outputAsAtelseifAsAtxthe
fi
dst1elseAsAtfi
ds1te
dife
dife
dfi
d
66EX6_6输入:输出:
umcou
t1
xe
dEX6_6过程cou
tlowhighxifhighlowthe
ifAlowxthe
retur
1elseretur
0elsemidlowhigh2retur
cou
tlowmidcou
tmid1highe
dife
dcou
t
递归出口highlow
f651EX6_51输入:输出:hhighRretur
he
dEX6_51过程highTifT为空the
retur
1elselefthighTleftrighthighTrightretur
1maxleftrighte
dife
dhigh
递归出口Tleft
ulla
dTright
ullthe
retur
0全局变量?652算法SECONDVALUE输入:正整数
和存储
个元素的数组a1
输出:数组a的第二大元素x1x2seco
dvalue1
aretur
x2e
dSECONDVALUE过程seco
dvaluelowhigha返回数对x1x2其中x1x2ifhighlow0the
retur
alow∞这个地方有修改elseifhighlow1the
ifahighalowthe
retur
ahighalowelseretur
alowahighe
dife
dife
difmidlowhigh2x1x2seco
dvaluelowmiday1y2seco
dvaluemid1higha
fretur
x1x2y1y2中最大和最小元素对
fr
好听全球资料 返回顶部