using System;
public class GFG {
static public void sortArray(int []arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
int min_idx = i;
for (int j = i + 1; j < n; j++)
if (arr[j] % 2 != 0 && arr[j] > arr[min_idx])
min_idx = j;
int temp = arr[min_idx];
arr[min_idx] = arr[i];
arr[i] = temp;
}
static public void Main()
int []arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
sortArray(arr);
Console.WriteLine("Отсортированный массив:");
foreach (int x in arr)
Console.Write(x + " ");
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
using System;
public class GFG {
static public void sortArray(int []arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
int min_idx = i;
for (int j = i + 1; j < n; j++)
if (arr[j] % 2 != 0 && arr[j] > arr[min_idx])
min_idx = j;
int temp = arr[min_idx];
arr[min_idx] = arr[i];
arr[i] = temp;
}
}
static public void Main()
{
int []arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
sortArray(arr);
Console.WriteLine("Отсортированный массив:");
foreach (int x in arr)
Console.Write(x + " ");
}
}