c#实现冒泡排序算法和斐波拉契数列的算法 电脑版发表于:2023/3/7 15:57 **冒泡排序算法的C#代码实现如下:** ``` public static void BubbleSort(int[] arr) { int n = arr.Length; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } } ``` **斐波拉契数列的C#代码实现如下:** ``` public static int Fibonacci(int n) { if (n <= 1) { return n; } int a = 0, b = 1, c = 0; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return c; } ```