zoukankan      html  css  js  c++  java
  • 面向对象练习1

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    
    namespace ConsoleApplication40
    {
        class Program
        {
            struct student
            {
                public string xueshengname;
                public int xuehao;
                public int fenshu;
            }
            public ArrayList paixu(ArrayList al)
            {
                for (int i = 0; i < al.Count; i++)
                {
                    for (int j = i; j < al.Count - 1; j++)
                    {
                        if (((student)al[i]).fenshu < ((student)al[j + 1]).fenshu)
                        {
                            student temp = (student)al[i];
                            al[i] = al[j + 1];
                            al[j + 1] = temp;
                        }
                    }
                }
                return al;
    
            }
            static void Main(string[] args)
            {
                ArrayList al = new ArrayList();
                student a = new student();
                Console.WriteLine("请输入人数");
                int n = Convert.ToInt32(Console.ReadLine());
                for (int i = 0; i < n; i++)
                {
                    Console.WriteLine("请输入第"+(i+1)+"人的姓名");
                    a.xueshengname = Console.ReadLine();
                    Console.WriteLine("请输入第" + (i + 1) + "人的学号");
                    a.xuehao = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("请输入第" + (i + 1) + "人的成绩");
                    a.fenshu = Convert.ToInt32(Console.ReadLine());
                    al.Add(a);
                }
                new Program().paixu(al);
                for (int i = 0; i < n; i++)
                {
                    Console.WriteLine((((student)al[i]).xueshengname) + "	" + (((student)al[i]).xuehao) + "	" + (((student)al[i]).fenshu));
                }
                Console.ReadLine();
            }
        }
    }
  • 相关阅读:
    quartz CronExpression表达式
    nginx配置文件说明
    mysql的日期输出格式列出来
    linux配置定时备份mysql数据库
    Nginx 配置
    查看mysql 服务有哪些ip地址在连接。
    对HelloWorld进行探究
    SpringBoot热部署与启动速度优化
    SpringBoot 快速入门
    初始SpringBoot
  • 原文地址:https://www.cnblogs.com/wwJ0312/p/4520161.html
Copyright © 2011-2022 走看看