20141021--Two-dimensional arrays

Source: Internet
Author: User

Two-dimensional arrays::

int[,] ss = new int[3, 5] {{0, 1, 2, 3, 4}, {5, 6, 7, 8, 9}, {10, 11, 12, 13, 14}};

A two-dimensional array, Int[x,y] represents an X array, each containing Y elements

Value, Ss[m,n] represents the nth element of the number of arrays of M. The M,n index starts at 0.

The Foreach loop is only for array loops.

Exercise 1

1Console.Write ("Please enter the total number of courses:");2             intm =int. Parse (Console.ReadLine ());3Console.WriteLine ("Please enter the course name (note that the order of entry for this course will be the order of the following scores)");4             string[] Kecheng =New string[M];//The string array Kecheng, starting with 0, contains the course names entered sequentially,5              for(intp =0; P < m; p++)6             {7Console.Write ("Please enter section"+ (P +1) +"Course Name:");8KECHENG[P] =console.readline ();9             }TenConsole.Write ("Please enter the number of people:"); One             intn =int. Parse (Console.ReadLine ()); A             Double[,] Shuzu =New Double[N, M]; -              for(inti =0; I < n; i++) -             { theConsole.WriteLine ("Please enter section"+ (i +1) +"Personal Score:"); -                  for(intj =0; J < M; J + +) -                 { -Console.Write ("Please enter"+ Kecheng[j] +"Score:"); +Shuzu[i, J] =Double. Parse (Console.ReadLine ()); -                 } +             } A console.readline (); at             Doubleping =0; -              for(intK =0; K < M; k++)//m is the total number of courses K -             { -                  for(intp =0; P < n; p++)//N is the number of P -                 { -ping = ping +Shuzu[p, K]; in                     //each cycle once the course m constant K, change n person p, -                 } toConsole.WriteLine (kecheng[k]+"The average score of the course"+ping/n); +             } -Console.ReadLine ();

20141021--Two-dimensional arrays

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.