首页 > 其他分享 >EXAM4-3

EXAM4-3

时间:2023-10-17 17:37:08浏览次数:40  
标签:return s2 s1 next EXAM4 print LinkString

from LinkString import LinkString

def StrEqueal(s,t):
if s.getsize()!=t.getsize(): #不等长一定不相等
return False

p=s.head.next
q=t.head.next
while p!=None and q!=None:
if p.data!=q.data: #等长时对比对应位字符是否相同
return False
p=p.next
q=q.next
return True;

cstr1="abcd"
s1=LinkString()
s1.StrAssign(cstr1)
print("s1: ",end='');s1.DispStr()

cstr2="abcd"
s2=LinkString()
s2.StrAssign(cstr2)
print("s2: ",end='');s2.DispStr()
print(StrEqueal(s1,s2))

 

标签:return,s2,s1,next,EXAM4,print,LinkString
From: https://www.cnblogs.com/simple-one/p/17770232.html

相关文章

  • EXAM4-2
    fromSqStringimportSqStringdefStrcmp(s,t):minl=min(s.getsize(),t.getsize())#求s和t中最小长度foriinrange(minl): #在共同长度内逐个字符比较ifs[i]>t[i]:return1elifs[i]<t[i]:return-1ifs.getsize()......
  • EXAM4-5
    fromLinkStringimportLinkStringdefBF1(s,t):#链串的BF算法p=s.head.next #p指向s串的首结点i=0 #i为p指的首结点的序号为0whilep!=None:p1=p;q=t.head.next #q指向t串的首结点whilep1!......