吉林大学2002年考研c语言程序设计答案真题ahrefhttpwwwpassecom真题网提供abr20021函数名称2002_1c程序目的递归地将一个数插入一个准递增序列且插入完毕后仍然保持准递增特性Write
byApech
SoftLabofJLUi
cludestdiohstruct
ode定义链表结点结构在最前面给出i
t
um
ode
ext
odei
sert
odeheadi
t
题目要求的函数
odepif
head
um若
已经到了准递增序列的合适的位置递归出口p
odemallocsizeof
ode新建一个节点用来存放
p
um
p
extheadheadpelsei
serthead
ext
否则递归插入retur
head20021函数名称2002_2c函数目的求给定序列的最长递增子序列的长度Write
byApech
SoftLabofJLUi
cludestdiohco
sti
tN8i
tMaxLe
gi
ta
fi
tile
1lmax1fori1iNiifaiai1如果满足递增子序列的定义le
增一le
co
t
ueiflamxle
lmaxle
le
1retur
lmax20023函数名称2004_3c函数目的用链表表示集合的相加Write
byApech
SoftLabofJLUi
cludestdiohstruct
ode定义链表结点结构在最前面给出i
t
um
ode
exti
tismemberi
ta
odehead子函数判断整数a是不是在以head为头结点的链表中i
tsig
0如果在返回1否则返回0
odepheadifpNULL注意集合为空集的情况retur
sig
whilepNULLifp
umasig
1breakpp
ext
fretur
sig
odeSetAdd
odeP
odeQ题目要求的函数i
t
odertailpoi
t1poi
g2ifPNULLretur
QifQNULLretur
PrPwhilerNULLtail用来记录P链表的尾部tailrrr
extrQwhileismemberr
umP找到Q中第一个不在P中的元素的位置记为rrr
extpoi
t1rpoi
g2r
extwhilepoi
t2NULL从r开始遍历链表Q
poi
t2
umifismember
Ppoi
t1
extpoi
t2
ext如果遍历到的元素是P中的元素那么把它删掉elsepoi
t1poi
t2否则继续poi
t2poi
t2
exttail
extr把剩余的元素放到P中retur
P2002_4函数名称2004_4r