算法小练习
倒排:
a="shdjcdda" p="" count=0 for j in range(0,len(a)) : for i in range(0,len(a)) : if j<=i : t=a[i-count] count=count+1 p+=t print(p)
排序:
__author__ = 'Administrator' a=[5,8,16,1,74,2,3,85,24] t=[] for i in range(0,len(a)) : for j in range(0,len(a)) : if a[i]<a[j]: t=a[i] a[i]=a[j] a[j]=t print(a)
算重复:
__author__ = 'Administrator' a=[5,3,16,5,74,5,3,85,24] t=[] for i in a : count=0 for j in a : if i==j: count=count+1 if count>1: if i not in t: t.append(i) print(i,count)