zoukankan      html  css  js  c++  java
  • 结构体

      //结构体 定义自己的类型my tape

                //在main括号外面加public stuct **  **为自己的类型  下边加大括号  括号里是自己的类型里面包括的对象

                //在里边写 public +类型+变量名   类型里面可以加自己创建的类型  

                //把 中间的class 去掉,新添加的其他新建项也可以用 这个类型

                //例

     

                 /*

                 public struct snakepoint

                 {

                     public int x;

                     public  int y;

                 }

               public  struct student

                      {

                          public int 学号;

                          public string 名字;

                          public int csharp;

                          public int 网页;

                          public int 数据库;

                          public int 总分;

                          public int 名次;

                          public snakepoint 坐标;

                       }

     

              

                     snakepoint s = new snakepoint();

                    s.x = 5;

                    s.y=10;

                    ArrayList a = new ArrayList();

                    a.Add(s);

                    Console.WriteLine(((snakepoint)a[0]).x+","+((snakepoint)a[0]).y);

                */

              

     

     

     

     

                //输入学生信息并成绩排名

                /*

                //输入部分  加求总成绩

                Console.WriteLine("请输入信息:");

                 student []a=new student [5];

                for (int i = 0; i < 5;i++ )

                {

                    a[i].学号 =i+1;

                    Console.Write("输入名字:");

                    a[i].名字 = Console.ReadLine();

                    Console.Write("输入c#成绩:");

                    a[i].csharp = Convert.ToInt32(Console.ReadLine());

                    Console.Write("输入网页成绩:");

                    a[i].网页 = Convert.ToInt32(Console.ReadLine());

                    Console.Write("输入数据库成绩:");

                    a[i].数据库 = Convert.ToInt32(Console.ReadLine());

                  

                    a[i].总分 = a[i].csharp + a[i].数据库 + a[i].网页;

                  

                } 

                

                

                //根据总分排名

                for (int i = 0; i < 5; i++)

                {

                    for (int m = 0; m < i; m++)

                    {

                        if (a[m].总分 < a[i].总分)

                        {

                            student n = a[m];

                            a[m] = a[i];

                            a[i] = n;

                        }

                       

                    }

                 

                }

                 //输出部分

                Console.WriteLine("学号 姓名 c# 网页 数据库 总分 名次");

                for (int i = 0; i < 5;i++ )

                {

                    a[i].名次 = i + 1;

                    Console.WriteLine(a[i].学号 +" "+a[i].名字 +" "+a[i].csharp+" "+a[i].网页+" "+a[i].数据库+" "+a[i].总分+" "+a[i].名次);

                }

     

                */

  • 相关阅读:
    复利计算- 结对
    《构建之法》第4章读后感
    复利计算--单元测试
    实验一 命令解释程序的编写实验
    Scrum 项目准备4.0
    Scrum 项目准备3.0
    scrum 项目准备2.0
    【操作系统】实验三 进程调度模拟程序
    scrum 项目准备1.0
    Scrum团队成立
  • 原文地址:https://www.cnblogs.com/wanwuguizong/p/3939336.html
Copyright © 2011-2022 走看看