指定された数の不規則な整数を降順にソートする関数を C 言語で定義します。

不規則な整数の降順ソートを実装する 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; 
  }

}

おすすめ

転載: blog.csdn.net/weixin_35756373/article/details/129528513