Categories
News

Working With Arrays

We continue to work with arrays. So given a one-dimensional or two-dimensional array. It is often necessary to find in it some element, such as maximum or minimum, or equal to this element. Consider the one-dimensional array. For the required element is usually isolated variable, but it does not necessarily preserve the value of the element, and it is desirable to maintain the number (index) element found.

In this case there are two plus: first a variable type to virtual arrays can be defined integer, second, if you want to do something with the items found it did not need to look again, and the value of the element found can be obtained using just such a write a k, where a – the array, k – the number (index) of the desired item. Consider the two-dimensional array. If given a two-dimensional array, and we need to find the element, which in consequence zatemu need to be changed with another element or What do the shift, while desirable as a one-dimensional set variables to store the row and column in which the element found. So, to summarize, if you want to find items and carry with them what that work, or withdraw its location, then you must specify the variables that will store the location of the desired element, if it works with found items will not be, for example, will need to find just the maximum or minimum element in the two-dimensional array, then we can define a variable of the same type as the array. And remember when try to do programming tasks that they worked as much as possible less, although the computer and iron, do not overload it.