sort an array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

sort an array

Arrange the even elements in ascending order and in descending order the odd elements of one array of at least 5 elements, numbers whole two digits each. Will be used both methods: SelectionSort & BubbleSort. Exemple: input: 5 64 25 16 81 49 36 output: 16 25 36 49 64 81 I tried something, didn't worked. https://code.sololearn.com/c2QXwKFVn1SR/#cpp

6th Feb 2020, 4:47 PM
George Listru
George Listru - avatar
6 Answers
+ 6
Would you kindky learn reading error messages?!! There are two simple brackets missing. I won't tell you where... Anyways.. good job. Your prog is not so bad.
6th Feb 2020, 5:00 PM
Oma Falk
Oma Falk - avatar
6th Feb 2020, 4:49 PM
Avinesh
Avinesh - avatar
+ 4
#include <bits/stdc++.h> using namespace std;    int main() {     int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};     int n = sizeof(arr)/sizeof(arr[0]);        sort(arr, arr+n);        cout << "\nArray after sorting using "          "default sort is : \n";     for (int i = 0; i < n; ++i)         cout << arr[i] << " ";        return 0; }
6th Feb 2020, 5:02 PM
Ajay Singh
Ajay Singh - avatar
+ 2
Avinesh 😂 both from Moldova.
6th Feb 2020, 4:59 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
Very easy by using sort fn from stl
6th Feb 2020, 5:01 PM
Ajay Singh
Ajay Singh - avatar
0
Please follow and upvote if the answer helped you :)
6th Feb 2020, 5:06 PM
Ajay Singh
Ajay Singh - avatar