第一题 方形输出
string=input()
lenth=len(string)
k=lenth//4
results=[]
for i in range(k+1):
result=[]
for j in range(k+1):
result.append(" ")
results.append(result)
flag=1
count=0
for i in range(lenth):
if flag==1:
results[0][i%k]=string[i]
count=count+1
if flag==2:
results[i%k][k]=string[i]
count=count+1
if flag==3:
results[k][k-i%k]=string[i]
count=count+1
if flag==4:
results[k-i%k][0]=string[i]
count=count+1
if count==k:
flag=flag+1
count=0
for i in range(k+1):
rstr=""
for j in range(k+1):
rstr=rstr+results[i][j]
print(rstr)
第三题寻找最熟悉的陌生人 n,num=map(int,input().split())
friends=[]
for i in range(n):
friend=list(map(int,input().split()))
friends.append(friend)
maxcount=0
nums=-1
for i in range(n):
if i!=num:
if num in friends[i]:
continue
else:
count=0
for j in range(len(friends[num])):
if friends[num][j] in friends[i]:
count=count+1
if count>maxcount:
maxcount=count
nums=i
print(nums)
第二题数字分组 num=input()
lenth=len(num)
count=0
for i in range(1,lenth):
num1=num[:i]
num2=num[i:]
if (num1[0]!='0' and num2[0]!='0') or (len(num1)==1 and num2[0]!='0') or (num1[0]!='0' and len(num2)==1) or (len(num1)==1 and len(num2)==1):
count=count+1
if (len(num1)!=1 and num1[len(num1)-1]!='0') and (num2[0]!='0' or len(num2)==1):
if num1[0]=='0':
count=count+1
else:
count=count+len(num1)-1
if (num1[0]!='0' or len(num1)==1) and len(num2)!=1 and num2[len(num2)-1]!='0':
if num2[0]=='0':
count=count+1
else:
count=count+len(num2)-1
if len(num1)!=1 and num1[len(num1)-1]!='0' and len(num2)!=1 and num2[len(num2)-1]!='0':
if num1[0]=='0' and num2[0]=='0':
count=count+1
if num1[0]=='0' and num2[0]!='0':
count=count+len(num2)-1
if num1[0]!='0' and num2[0]=='0':
count=count+len(num1)-1
if num1[0]!='0' and num2[0]!='0':
count=count+(len(num1)-1)*(len(num2)-1)
print(count)
第四题不会
#拼多多##笔试题目#