mirror of
https://github.com/Sheldoer/Suda_examination_notes.git
synced 2026-06-17 15:46:36 +08:00
Delete 复试笔记/21笔试代码 directory
真题修改
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
def find_next(L):
|
||||
length=len(L)
|
||||
res=[]
|
||||
for i in range(length):
|
||||
flag=0 #flag
|
||||
for j in range(i+1,length):
|
||||
if L[j]>L[i]:
|
||||
res.append(L[j])
|
||||
flag=1
|
||||
break
|
||||
if flag==0:
|
||||
res.append(None)
|
||||
return res
|
||||
if __name__=='__main__':
|
||||
L=[2,3,5]
|
||||
L=[5,2,3]
|
||||
print(find_next(L))
|
||||
@@ -1,20 +0,0 @@
|
||||
def find_pair(L):
|
||||
length=len(L)
|
||||
mxmul=L[0]*L[1]
|
||||
indext=(L[0],L[1])
|
||||
for i in range(length):
|
||||
for j in range(i+1,length):
|
||||
if L[i]*L[j]>=mxmul:
|
||||
mxmul=L[i]*L[j]
|
||||
indext=(L[i],L[j])
|
||||
indext=list(indext)
|
||||
indext.sort()
|
||||
return (indext[0],indext[1])
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
#L=[1,-1,0]
|
||||
L=[-10,-3,5,6,-2]
|
||||
print(find_pair(L))
|
||||
@@ -1,10 +0,0 @@
|
||||
def find_number(n):
|
||||
res=[]
|
||||
for i in range(n+1):
|
||||
s=bin(i)[2:] #remove '0b'
|
||||
if s.count('1')>s.count('0'):
|
||||
res.append(i)
|
||||
return res
|
||||
if __name__=='__main__':
|
||||
print(find_number(15))
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
def find_major(L):
|
||||
length=len(L)
|
||||
lst=[]
|
||||
res=set()
|
||||
for i in L:
|
||||
for j in list(i):
|
||||
lst.append(j)
|
||||
for i in set(lst):
|
||||
if lst.count(i)>length/2:
|
||||
res.add(i)
|
||||
if len(res)>0:
|
||||
return res
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
L=[{1},{1,2},{1}]
|
||||
L=[{1},{2,3}]
|
||||
print(find_major(L))
|
||||
|
||||
Reference in New Issue
Block a user