zoukankan      html  css  js  c++  java
  • C# 递归算法与冒泡

    C# 递归算法求 1,1,2,3,5,8,13···
    static void Main(string[] args)
    {

    int[] cSum = new int[10];
    for (int i = 0; i < cSum.Length; i++)
    {
    cSum[i] = Pro_WriteNum(i);
    Console.WriteLine(cSum[i]);
    }
    Console.ReadLine();
    }

    private static int Pro_WriteNum(int a)
    {
    int result = 0;
    if (a == 0 || a == 1)
    {
    result = 1;
    }
    else
    {
    result = Pro_WriteNum(a - 1) + Pro_WriteNum(a - 2);
    }
    return result;

    }
    -------------------------------------------------------------
    int temp;
    int[] arrSort = new int[] { 10, 8, 3, 5, 6, 7, 9 };
    for (int i = 0; i < arrSort.Length; i++)
    {
    for (int j = i + 1; j < arrSort.Length; j++)
    {
    if (arrSort[j] < arrSort[i])
    {
    temp = arrSort[j];
    arrSort[j] = arrSort[i];
    arrSort[i] = temp;
    }
    }
    }

  • 相关阅读:
    高频交易程序竟然是饿罗斯人开发的?
    系统功能在用户测试阶段被推翻
    去新华书店有感
    金桔
    结香
    金钟花
    金丝桃
    箬竹
    香茶菜
    水果兰
  • 原文地址:https://www.cnblogs.com/chengjun/p/5383731.html
Copyright © 2011-2022 走看看