解题思路:
可以把碰头回头改为交叉带病,完全等价
参考代码:
n=int(input())
q=list(map(int,input().split()))
x=q[0]
num=1
for i in range(n):
for j in range(i,n):
if abs(q[i])>abs(q[j]):
q[i],q[j]=q[j],q[i]
for i in range(n):
if q[i]==x:
x=i
break
if q[x]>0:
for i in range(x+1,n):
if q[i]<0:
num=num+1
if num>=2:
for i in range(0,x):
if q[i]>0:
num=num+1
elif q[x]<0:
for i in range(0,x):
if q[i]>0:
num=num+1
if num>=2:
for i in range(x+1,n):
if q[i]<0:
num=num+1
print(num)
看完记得点个赞
0.0分
0 人评分