不規則な整数の降順ソートを実装する C 言語の関数の例を示します。 void sort(int arr[], int n) { int i, j, temp; for (i = 0; i < n-1; i++)
for (j = 0; j < n-i-1; j++)
if (arr[j] < arr[j+1])
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
不規則な整数の降順ソートを実装する C 言語の関数の例を示します。 void sort(int arr[], int n) { int i, j, temp; for (i = 0; i < n-1; i++)
for (j = 0; j < n-i-1; j++)
if (arr[j] < arr[j+1])
{
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}