Assign three people a score of Console.WriteLine ("Input number"); int n = Int. Parse (Console.ReadLine ()); double[,] Shuzu = new double[n, 3];for (int i = 0; i < n; i++) { Console.WriteLine ("Input" + (i + 1) + "personal score"); Console.WriteLine ("Input language score:"); shuzu[i, 0] = double. Parse (Console.ReadLine ()); Console.WriteLine ("Input math score:"); shuzu[i, 1] = double. Parse (Console.ReadLine ()); Console.WriteLine ("Input English Score:"); shuzu[i, 2] = double. Parse (Console.ReadLine ()); }
Defines a collection, which is a class that, in the System.Collections library, needs to be referenced first
Rraylist al = new ArrayList ();
A collection is like an array, the index starts at 0, and a collection best places a type of data
int I=al. ADD (3);//value, object any data can be put
int J=al. Add ("Confucius");//The value returned is a string type, which is the index of the added data in the collection
int K=al. Add (6);//returns the int type, which is the index of the added data in the collection
Console.WriteLine (i+ "" + "" +j+ "" +k);//read out index
Console.readkey ();
Defines a collection, which is a class that, in the System.Collections library, needs to be referenced first
ArrayList al = new ArrayList ();//Set as an array, the index starts at 0, and a collection best places a type of data
int I=al. ADD (3);//value, object any data can be put
int J=al. ADD ("Confucius");
int K=al. ADD (1);
Al. Insert (1,9);//inserted into the 1th back 9, the original unknown index followed by a
Al. Insert (2,9);//Insertion to 2nd back 9
Console.WriteLine (Al[0]);
Console.WriteLine (Al[1]);
Console.WriteLine (Al[2]);
Console.WriteLine (Al[3]);
Console.WriteLine (i+ "" + "" +j+ "" +k);//read out index
Console.readkey ();
Al. Remove (value is the value on that index);//al.removeat ();
ArrayList al = new ArrayList ();//Set as an array, the index starts at 0, and a collection best places a type of data
int I=al. ADD (3);//value, object any data can be put
int J=al. ADD (5);
int K=al. ADD (1);
Al. Insert (1,9);//inserted into the 1th back 9, the original unknown index followed by a
Al. Remove (3);//delete the value in the first index above, 3,, change to 951,
Al. RemoveAt (0);//Deletes the value on the specified index. The value 3 on index 0 has been removed and changed to 951
Console.WriteLine (Al[0]);
Console.WriteLine (Al[1]);
Console.WriteLine (Al[2]);
Console.WriteLine (Al[3]);
Console.WriteLine (i+ "" + "" +j+ "" +k);//read out index
Console.readkey ();
Define a collection, a collection is a class, in the System.Collections library, you need to refer to ArrayList al = new ArrayList ();//Set as an array, index starting from 0, a collection preferably put a type of data int I=al. ADD (3);//value, object what data can be put int j=al. ADD (5); int K=al. ADD (1); int C = al. ADD (3);//value, object any data can be put int b = al. ADD (4); int Cc=al. count;//calculates the value//al inside the set. Remove (3);//delete the value in the first index above, 3, and change to 5134, removing only the first occurrence of the 3//al. RemoveAt (3);//Deletes the value on the specified index. The value 3 on index 3 has been removed and changed to 3534 Console.WriteLine (Al[0]); Console.WriteLine (Al[1]); Console.WriteLine (Al[2]); Console.WriteLine (Al[3]); Console.WriteLine (Al[4]); Console.WriteLine (cc);//Output 5 value console.readkey (); ArrayList al = new ArrayList (); Console.WriteLine ("Please enter the number of people"); int n = Int. Parse (Console.ReadLine ()); for (int i =0; I <n;i++) {Console.WriteLine ("Please enter fractions"); Al. ADD (Console.ReadLine ()); } double sum = 0; for (int k=0;k<n;k++) {sum+=double. Parse (Al[k]. ToString ()); } double avg=sum/n; Al. Sort (); Console.WriteLine ("The total score of the number you entered is {0}, the average is {1}", Sum,avg); Sort. From small to large al. Sort ();//alphabetical or string, for (int d = 0; d < n;d++) {Console.WriteLine (al[d]); } console.readline (); Sort. From the big to the small al. Sort (); Al. Reverse ();//Invert function for (int d = 0; d < n;d++) {Console.WriteLine (al[d]); } console.readline (); ArrayList al = new ArrayList (); Console.WriteLine ("Please enter the number of people"); int n = Int. Parse (Console.ReadLine ()); for (int i =0; I <n;i++) {Console.WriteLine ("Please enter fractions"); Al. ADD (Console.ReadLine ()); If the number is stored, in the future when the size of the time, need to add the time to first convert to a numeric type, Added to the collection otherwise, the size of the encoding area of the string will be compared, error} double sum = 0; for (int k=0;k<n;k++) {sum+=double. Parse (Al[k]. ToString ()); } double avg=sum/n; Console.WriteLine ("The total score of the number you entered is {0}, the average is {1}", Sum,avg); int sy = al. IndexOf ("12");//Index of 12, if output-1 that is not found, only the index of the first match is returned int sy1 = al. LastIndexOf ("12");//Returns the value of the last occurrence Console.WriteLine ("Index is" + sy+ "The last Index is" +sy1 ");//Compare the data types to see if they match. Otherwise it is less than the for (int d = 0; d < n;d++) {Console.WriteLine (al[d]); } console.readline (); ArrayList al = new ArrayList (); Console.WriteLine ("Please enter the number of people"); int n = Int. Parse (Console.ReadLine ()); for (int i =0; I <n;i++) {Console.WriteLine ("Please enter fractions"); Al. ADD (double. Parse (Console.ReadLine ())); If the number is saved, in the future when the size of the time, need to add the time before the conversion to a numeric type,//added to the collection or, the size is compared as the encoding area of the string, and an error occurs} double sum = 0; for (int k=0;k<n;k++) {sum+=double. Parse (Al[k]. ToString ()); } double avg=sum/n; Console.WriteLine ("The total score of the number you entered is {0}, the average is {1}", Sum,avg); int sy = al. IndexOf (12.0);//Index of 12, if output-1 that is not found, only the index of the first match is returned int sy1 = al. LastIndexOf (12.0);//Returns the value of the last occurrence Console.WriteLine ("Index is" + sy+ "The last Index is" +sy1 ");//Compare the data types to see if they match. Otherwise it is less than the for (int d = 0; d < n;d++) {Console.WriteLine (al[d]); }console.readline ();
Int[,]sss=new int[3,5]{{99,2,3,4,5},{1,2,3,43,5},{1,2,5,4,58}};
0 1 2 3 4 0 1 2 3 4 0 1 2 3 4
0 1 2
Console.Write (sss[0.0]); take it out. 99
Console.Write (sss[1.3]); take it out. 43
Console.Write (sss[2.4]); take it out. 58
October 21, 2014------Array, collection