One, array
1, definition: is a data type of a combination of data, arrays are used to group basic types or objects of the same type. An entity in an array is called an element or member of an array.
2. Format:int[] shuzu=new int[6]; Holds the number of array of type int. For example:6;
int[] shuzu=new(Initialize) int[6]{1,2,3,4,5,6}; the original method of assigning is to add the parentheses at the end and separate the number you want to store, separated by commas.
Note: Arrays are indexed , numbering starts with 0 ;
1) Want to remove the number "3" from the inside, the specific operation is as follows:
Int[] shuzu=new int[6]{1,2,3,4,5 ,6}
Int i=shuzu[2];
Console.Write (i);
2) Assignment Method 2: An assignment of one value.
Int[] shuzu=new int[6];
Shuzu[0]=1;
shuzu[1]=2;
shuzu[2]=3;
Console.Write (5);
Note: If the initialization, only three of the assignment, the other is not assigned, then enter a non-assigned index, the output is 0;
Exercise 1: Enter the score, the average score, the highest score and the lowest score;
Exercise 2: Input results, sorted by size;
Exercises 3:
Second, equal substitution
In the above question, we use the equivalent substitution to solve will be more easy to understand, for example: a=1,b=2 want to have a and B assigned value Exchange, need to take an intermediate value C, they can be switched to achieve. Similarly, in order to sort the problem, we can use this method, according to from the big to the small or from the smallest to the big order.
A=1;
b=2;
Median value c=0;
C=a; A=b; B=c, you can exchange values for a and B.
Third, the statement---the foreach is only for the numeric type array to operate, facilitates the computation management of the logarithm group;
The format is:
foreach (int d in s)//Note: D is a set of values contained in the array s, typically used when sorting the size or outputting a set of values.
{
Console.Write (d);
}
Iv. according to the type of learning (String, DateTime) of the previous lesson, the knowledge learned is practiced, and it is necessary to apply it in the exercises.
Exercises 1:
10-20c# Base---One-dimensional arrays && bubble sort