//从大到小冒泡排序
public void BubbleSort(int[] array) {
    for (int i = 0; i < array.Length - 1; i++) {
        for (int j = 0; j < array.Length - 1 - i; j++) {
            if (array[j] < array[j + 1]) {
                int temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }
        }
    }
}


//一列数的规则如下: 1、1、2、3、5、8、13、21、34......  求第30位数是多少, 用递归算法实现。
public static int Foo(int i) {
    if (i <= 0) {
        return 0;
    }
    else if (i > 0 && i <= 2) {
        return 1;
    }
    else {
        return Foo(i - 1) + Foo(i - 2);
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-08-15
  • 2022-01-28
  • 2021-07-06
  • 2022-12-23
  • 2021-05-11
  • 2021-12-05
猜你喜欢
  • 2022-02-21
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2021-12-18
相关资源
相似解决方案