您好,我觉得您在我上一个提的问题的回答得很好,思路很清晰,能不能帮我看一下这个问题,我实在没有头绪
万分感谢Createaprogramthatimplements“BubbleSort”onanunsortedarrayofintegers.HintsCreateab...
万分感谢
Create a
program that implements “Bubble Sort” on an unsorted array of integers.
Hints
Create a bool variable to tell you if the array issorted – it is sorted if you get from the beginning to the end without swappingany values.
You will need to use loops.
You will need to iterate to the second to last elementin the array only!
Bubble Sort
While the array is not sorted: (sorted = false)
Set sorted to true.
Starting at index 0, compare the current index to thenext index. If the element at the next index is greater, swap them (and setsorted to false), otherwise do nothing.
Increment your index.
C++的 展开
Create a
program that implements “Bubble Sort” on an unsorted array of integers.
Hints
Create a bool variable to tell you if the array issorted – it is sorted if you get from the beginning to the end without swappingany values.
You will need to use loops.
You will need to iterate to the second to last elementin the array only!
Bubble Sort
While the array is not sorted: (sorted = false)
Set sorted to true.
Starting at index 0, compare the current index to thenext index. If the element at the next index is greater, swap them (and setsorted to false), otherwise do nothing.
Increment your index.
C++的 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询