华为的几道笔试题
华为考试遇到了几个笔试题目,先记一下,有些题得重新做、 笔试信息试卷名称:【华为2019年校园招聘】2019-9-11 软件题 考试时间:(北京时间,UTC+08:00)09-11 19:00:00 – 21:10:00 考试时长:120分钟 考试地址:https://exam.nowcoder.com/cts/17045150/summary?xxxxxxxxxxxx(考试地址为你的私人专属地址,请勿转发。如无法直接打开,请拷贝完整链接并粘贴至浏览器地址栏) 硬件模拟试卷链接:https://www.nowcoder.com/cts/9540163/summary 软件模拟试卷链接:https://www.nowcoder.com/cts/9540156/summary 注:可提前进入模拟试卷链接熟悉题型和考试环境,方便您更顺利通过考试。 数轴相邻点问题 题目描述 s 解答 s=input() A=[] B=[] R=0 area="" s=s.replace("{","").replace("}","").replace("=",",") for x in s.split(","): if x in "ABR": area=x elif x in "={}": pass else: if area=="A": A.append(int(x)) elif area=="B": B.append(int(x)) elif area=="R": R=int(x) else: raise ValueError i=0 j=0 na=len(A) nb=len(B) sj=0 while i<na: while sj<nb and A[i]>B[sj] : sj+=1 if sj>=nb: break j=sj while j<nb and B[j]-A[i]<=R : print("(%s,%s)"%(A[i],B[j]),end="") j+=1 if j==sj: print("(%s,%s)"%(A[i],B[j]),end="") i+=1 print() 字符串倒序排列问题 题目描述 解答 import string CHR=string.digits+string.ascii_letters s=input() l=[] n=len(s) i=0 while i<n: if s[i] in CHR: l.append("") while i<n and (s[i] in CHR or s[i]=="-"): if s[i]=="-": if not(i+1<n and s[i+1] in CHR): break l[-1]+=s[i] i+=1 else: i+=1 print(" ".join(l[::-1]),end=" ") 航班线路问题 题目描述 ...