第二题我用python写了个,贪心 再处理下输入输出就可以用了哈 a = [3,5,1,2,3] for index in range(len(a)-1): if (index % 2 == 0) and (a[index] < a[index+1]): a[index], a[index+1] = a[index+1], a[index] if (index % 2 == 1) and (a[index] > a[index+1]): a[index], a[index+1] = a[index+1], a[index] print(a)
点赞 3

相关推荐

10-06 12:46
门头沟学院 Java
跨考小白:定时任务启动
点赞 评论 收藏
分享
牛客网
牛客企业服务