• 二维数组


       /*

                string s = "holle world";

                string[] a = s.Split(' ');//拆分符,里面可以加很多条件,用单引号阔起来

                //Console.WriteLine(a[0]);

                //Console.WriteLine(a[1]);

                for (int i = 0; i < a.Length; i++)

                {

                    Console.WriteLine(a[i]);

                }

                */

     

     

               //数组保证有序  二分法找数

                /*

                int[] a = new int[] {1,2,3,4,5,7,9,10};

                Console.Write("请输入你要找的数:");

                int m = Convert.ToInt32(Console .ReadLine());

                int x = 0, y = a.Length - 1, zj;

                while(y>=x)

                {

                    zj = (x + y) / 2;

                    if(m==a[zj])

                    {

                        Console.WriteLine("第{0}个数是你要找的数",zj);

                        break;

                    }

                    if(m>a[zj])

                    {

                        x = zj + 1;

                    }

                    if (m < a[zj])

                    {

                        y = zj - 1;

                    }

                }

                */

     

                //二维数组分标准a[2,3]和伪二维数组a[2][3]

                //标准的格式

                /*

                int[,] a = new int[2, 3]{{,,},{,,}};

                for(行)

                {

                for(列)

                {

                Console .Write (a[m,n]+" ");

                }

                Console .Write (" ");

                }

                */

                 //伪二维的格式

                /*

                 int[][] a=new int[2][];

                 int[] a1 = new int[2];

                 int[] a2 = new int[3];

                 a[0] = a1;

                 a[1] = a2;

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

                 {

                     for (int n = 0; n < a[i].Length; n++)

                     {

                     }

                 }

                 */

     

     

     

     

     

                //输入和输出的实例 成绩表

                /*

     

                int[,] a = new int[3, 5] ;

     

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

                {

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

                    {

                        Console.Write("请输入第{0}行第{1}列的值:",i,j);

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

                    }

                   

                }

                Console.WriteLine("刚才输入的内容是:");

                Console.WriteLine("学号 语文 数学 英语 理综");

     

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

                {

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

                    {

                        Console.Write(a[i, j] + " ");

                    }

                Console .Write (" ");

                }

                */

     

     

     

                //学生成绩表排名

               

                /*

                 int[,] a = new int[3, 6] ;

     

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

                 {

                     Console.Write("请输入第{0}位学生的学号:", i + 1);

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

                     Console.Write("请输入第{0}位学生的语文成绩:", i +1);

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

                     Console.Write("请输入第{0}位学生的数学成绩:", i +1);

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

                     Console.Write("请输入第{0}位学生的英语成绩:", i +1);

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

                     a[i, 4] = a[i, 1] + a[i, 2] + a[i, 3];

                     a[i, 5] = i + 1;

                 }

     

     

               

                 for (int i = 1; i < 3;i++ )

                 {

                     for (int j = 1; j < 4-i; j++)

                     {

                         if(a[j-1,4]<a[j,4] )

                         {

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

                             {

                                 int n = a[j - 1, m];

                                 a[j - 1, m] = a[j, m];

                                 a[j, m] = n;

     

     

                             }

                

                         }

                     }

                 }

                 Console.WriteLine("学号 语文 数学 英语 总分 排名");

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

                 {

                     for (int j = 0; j < 6; j++)

                     {

                         Console.Write(a[i, j] + " ");

                     }

                   

                   

                     Console.Write(" ");

                 }

                */

     

               

  • 相关阅读:
    .Net学习难点讨论系列2 – 细说C#中new关键字与多态
    [翻译]搜索关键字 – 管道与过滤器模式(PipesandFilters)与装饰模式(Decorator)之间的关系
    .Net学习难点讨论系列1 – 委托与事件之事件
    [翻译]Popfly系列课程1 Popfly课程计划概览
    常用桌面虚拟化软件横向对比
    各种算法的C#实现系列1 合并排序的原理及代码分析
    博客园安家
    疑:Microsoft® Silverlight™ Tools for Visual Studio 2008 SP1的版本让人困惑
    stream_socket_client
    stream_socket_client2
  • 原文地址:https://www.cnblogs.com/wanwuguizong/p/3936959.html
Copyright © 2020-2023  润新知