sort array

void Sort(int arr[], int n) { int temp; for (int i = 0;i < n - 1;i++) { for (int j = i + 1;j < n;j++) { if (arr[i] > arr[j] ) { swap(arr[i], arr[j]); } } } } void Sort1(int arr[], int n) { int temp; for (int i = 0;i < n - 1;i++) { for (int j = i + 1;j < n;j++) { if (arr[i] %2==0 >arr[j]%2==0) { swap(arr[i], arr[j]); } } } } int main() { int n = 10; int arr[10] = {4,3,1,5,10,99,101,200,23,22 }; Sort(arr, n); Sort1(arr, n); OutputArray(arr, n); system("pause"); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.