+ 1

how do are writw the code to arrange the following array in ascending order 200 190 100 96 102 82 122

15th Oct 2016, 11:51 AM
Leslie Jason
Leslie Jason - avatar
2 ответов
+ 2
If you have C++11, following would be one of the most efficient solutions. #include<algorithm> // function block begin int arr[]={200,190 /*rest of elements*/}; std::sort(std:: begin(arr), std::end(arr)); // now the array elements are ascendingly sorted // function block end If you want to implement a sorting algorithm yourself, read about quick sort. Otherwise don't try to reinvent the wheel. Use standard library implementations in generic cases like this. They are well optimized.
16th Oct 2016, 3:30 AM
Sumudu
Sumudu - avatar
0
use any of the sorting algorithm , you can use the easiest Bubble Sort algorithm to solve it.
15th Oct 2016, 12:16 PM
Prabhakar Jha
Prabhakar Jha - avatar