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