开发者社区> 问答> 正文

C#采用递归算法,实现数据排序,麻烦了,能写点注释最好

C#采用递归算法,实现数据排序,麻烦了,能写点注释最好

展开
收起
知与谁同 2018-07-20 17:46:49 4251 0
2 条回答
写回答
取消 提交回答
  • 杀人者,打虎武松也。
    C#里面实现数据很简单用个sort()就可以了~~~
    例如:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Collections;

    namespace 回答问题3
    {
    class Program
    {
    static void Main(string[] args)
    {
    int[] a = new int[5] { 1, 8, 5, 4, 6 };
    Array.Sort(a);
    foreach (int number in a)
    {
    Console.WriteLine(number);
    }
    }
    }
    }
    2019-07-17 22:55:10
    赞同 展开评论 打赏
  • 云栖社区聚能聊、问答管理员~发福利、搞怪,八卦我来,论技术、发话题、写博客你上!
    XmlDocument xd = new XmlDocument();
    StringBuilder S = new StringBuilder(); //创建一个StringBuilder 对象

    protected void Page_Load(object sender, EventArgs e)
    {
    xd.Load(Server.MapPath("xml/1.xml")); //标注XML文件的路径
    XmlNode gjd = xd.DocumentElement; //new 一个节点对象
    Getchild(gjd);
    Literal1.Text = S.ToString();
    }

    void Getchild(XmlNode myNode) //递归算法
    {
    if (myNode.HasChildNodes)
    {

    XmlNodeList xnl = myNode.ChildNodes;
    foreach (XmlNode xnf in xnl)
    {
    Getchild(xnf);
    }

    }
    else
    {

    S.Append(myNode.Value + "<br>");
    }

    }
    2019-07-17 22:55:10
    赞同 展开评论 打赏
问答分类:
问答地址:
相关产品:
问答排行榜
最热
最新

相关电子书

更多
数据+算法定义新世界 立即下载
袋鼠云基于实时计算的反黄牛算法 立即下载
Alink:基于Apache Flink的算法平台 立即下载