zoukankan      html  css  js  c++  java
  • 结构体数组排序

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;

    namespace 结构体冒泡排序
    {
        class Program
        {
            struct student
            {
                public string name;
                public int age;
            }
            static void Main(string[] args)
            {
                student[] a = new student[3];
                a[0].name = "约里克";
                a[0].age = 11;
                a[1].name = "掘墓者";
                a[1].age = 13;
                a[2].name = "德玛";
                a[2].age = 12;
                for (int i = 1; i <= a.Length; i++)
                {
                    for (int j = 1; j <= a.Length - i; j++)
                    {
                        if (a[j - 1].age < a[j].age)
                        {
                            student temp;
                            temp = a[j];
                            a[j] = a[j - 1];
                            a[j - 1] = temp;
                        }
                    }
                }
                Console.WriteLine("姓名为" + a[0].name + "年龄为" + a[0].age);
                Console.WriteLine("姓名为" + a[1].name + "年龄为" + a[1].age);
                Console.WriteLine("姓名为" + a[2].name + "年龄为" + a[2].age);
                Console.ReadLine();
            }
        }
    }

  • 相关阅读:
    MongoDB +JSON+JQuery.Pagination+Linq 实现无刷新分页
    DBHelper
    C# .Net动态调用webService
    .net 将图片文件转换成流输出到浏览器
    将mongodb作为服务
    .net 最简单文件上传支持跨服务器
    Windows Phone 7
    javascript中对Date类型的常用操作
    DataTable 转换JSON
    C# 实现 MemCache 监控管理工具
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4415464.html
Copyright © 2011-2022 走看看