当前位置:网站首页>MOOC Weng Kai C language week 7: array operation: 1. array operation 2. Search 3. preliminary sorting

MOOC Weng Kai C language week 7: array operation: 1. array operation 2. Search 3. preliminary sorting

2022-07-28 07:03:00 W.934

One 、 Array operations

1. Array operations

1. Array operations

In a given set of data , How to find out if a data exists .

2. Positioning during integration initialization

 

3. Size of array

sizeof Give the size of the contents occupied by the whole array , Unit is byte .

Number of array elements :sizeof(a)/sizeof(a[0])

sizeof(a[0]) Give the size of a single element in an array ,sizeof(a) Give the array size ; Divide to get the number of cells in the array .

benefits : If the initial data in the array is modified , No need to modify the traversal code .

4. The assignment of an array

  Traversal array :

  When an array is a function parameter , Often you have to pass in the size of the array with another parameter .

2. Array example : prime number

 

 prime[count++]==i;

 

 

Two 、 Search for

1. Linear search

Search for :

 

2. Two point search

Find numbers in an ordered array

Program :

 

 

3、 ... and 、 Sort preliminary

Selection sort

If the array itself is not sorted , To sort by sorting algorithm

原网站

版权声明
本文为[W.934]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280520328916.html