华为勇敢星实习生——机试题
'''题目一:
现有多组整数数组,需要将他们合并成一个新的数组。合并规则,从每个数组按顺序
取出固定长度的内容合并到新的数组中,取完的内容会删除掉,如果该行不足固定长度
或者已经为空,则直接取出剩余部分的内容放到新的数组中,继续下行。如样例1,
获得长度3,先遍历第一行,获得2.5.6 ;再遍历第二行,获得1,7.4;再循环回到第行.
获得7,9,5 ;再遍历第二行,获得1,7,4;再循环回到第1行,获得7.按顺序拼接成最终结果
'''
import sys
length =int(input())
input_list = []
target_list = []
target_str =""
for linein sys.stdin:
if line[0]is '\n':
break
input_list.append(line.strip())
#print(input_list)
for listin input_list:
target_list.append([str(i)for iin list.split(',')])
#print(target_list)
i =0
while target_list != []:
index_num = i%len(target_list)
i +=1
#print(index_num)
if target_list[index_num] == []:
target_list.pop(index_num)
continue
target_str +=','.join(target_list[index_num][0:length])+','
target_list[index_num] = target_list[index_num][length:]
target_str = target_str[0:-1]
print(target_str)
另一次笔试的第一题:
题目#-*- coding = utf-8 -*-
total_num =list(input())
compute_list = []
if total_num[1] !='+' and total_num[1] !='-':
compute_list.append(10*int(total_num[1])+int(total_num[0]))
i =2
else:
compute_list.append(int(total_num[0]))
i =1
while i
if total_num[i] =='+':
if total_num[i+2] !='+' and total_num[i+2] !='-':
compute_list.append(int(total_num[i+1])*10+int(total_num[i+2]))
else:
compute_list.append(int(total_num[i+1]))
elif total_num[i] =='-':
if total_num[i+2] !='+' and total_num[i+2] !='-':
compute_list.append((-1)*(int(total_num[i+1])*10+int(total_num[i+2])))
else:
compute_list.append((-1)*int(total_num[i+1]))
i +=1
sum =0
for iin compute_list:
sum += i
print(sum)