程序基于备用排序 [英] Program based on alternate sort

查看:94
本文介绍了程序基于备用排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入 - 1 2 3 4 5 6

输出-2 1 4 3 6 5

排序应类似于以下给定的顺序。这些数字可以是随机的。



我的尝试:



我试图改变我的立场。如果我是平等的。我把它增加一个。如果我是奇怪的。我把它减一。

Input- 1 2 3 4 5 6
Output-2 1 4 3 6 5
The sorting should be similar like in the given following sequence. The numbers can be random.

What I have tried:

I tried to change the position of i. If i is even. I increase it by one. If I is odd. I decrease it by one.

推荐答案

引用:

输入 - 1 2 3 4 5 6

输出-2 1 4 3 6 5

排序应类似于以下给定的顺序。这些数字可以是随机的。

Input- 1 2 3 4 5 6
Output-2 1 4 3 6 5
The sorting should be similar like in the given following sequence. The numbers can be random.



你的例子很糟糕,因为数字是连续的并且已经排序了,所有它显示的是输出对的交换。


Your example is bad because the numbers are consecutive and already sorted, All it show is a swap of pairs on output.

Quote:

我试图改变i的位置。如果我是平等的。我把它增加一个。如果我是奇怪的。我把它减一。

I tried to change the position of i. If i is even. I increase it by one. If I is odd. I decrease it by one.



不要尝试更改值,因为它会在2,3,4,5,6,7和2,4,6,8时失败。

只需做一个正常的排序,然后交换对。



我们不做你的HomeWork。

HomeWork我们不会在乞求其他人做你的工作时测试你的技能,它会让你思考并帮助你的老师检查你对你所学课程的理解以及你应用它们时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请展示您的代码并解释这个问题,我们可能会提供帮助。


Do not try to change values because it will fail on 2, 3, 4, 5, 6, 7 and on 2, 4, 6, 8.
Just do a normal sort, then swap pairs.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.


这篇关于程序基于备用排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆