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;
    }
    }
    }

  • 相关阅读:
    数据结构实验2-迷宫
    离散实验4
    关系代数中的除法运算
    数据库中什么叫象集
    (转)汇编-补码
    2014022201
    20140222
    2014022101
    代码20140221
    代码20140215
  • 原文地址:https://www.cnblogs.com/chengjun/p/5383731.html
Copyright © 2011-2022 走看看