In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people have no idea about how to use arrays in C language. therefore, this paper summarizes the causes and solutions of the problems. Through this article, I hope you can solve this problem.
The basic concept of 1 array
Array: a collection of data elements of the same type, which is a construction data type in C language.
These elements are sequentially stored in a certain area of memory.
2 array definition syntax array type array name [array size]
Array size: determines the number of elements that can be stored in the array.
Array size cannot be a variable, it can only be a literal value or a literal expression.
The C language compiler requires that the memory size of the array be determined during compilation.
The array size must be a positive integer greater than 0.
3 initialization of one-dimensional array 3.1 all initialization int arr [5] = {1,2,3,4,5}; / / arr [0]: 1//arr [1]: 2//arr [2]: 3//arr [3]: 4//arr [4]: 5
Initialization list: a list of values enclosed in curly braces and used to initialize an array, separated by commas.
The initialization list can only be used when defining the array, and you can no longer use the initialization list to assign values to the array after the array definition is complete.
Full initialization requires that the number of elements in the initialization list must be the same as the array size.
3.2 some elements are assigned initial values int arr [5] = {1,2,3}; / / arr [0]: 1//arr [1]: 2//arr [2]: 3//arr [3]: 0//arr [4]: 0
In actual development, the method of assigning initial values to some elements is usually used to initialize array elements, such as: int arr [100] = {0}
3. Omit the initial value int arr [] = {1, 2, 3, 4, 5}
When defining an array, you can omit the array size in parentheses if the initialization list is followed by an initialization list, and the number of values in the initialization list is the expected array size.
4 example of using one-dimensional array 4.1 to find the maximum, minimum, average # include int main (void) {int arr [10]; int 1, sum, max, min; / / command line to read 10 integers for (iS0; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.