Массив. Элементы массива. Сумма элементов массива, количество

Programming is a long, creative process. It is hard enough to learn anything in this area if you do not have any ability to understand the principles by which programs and applications should be built. Today we’ll talk about the array, the elements of the array and the simplest operations with them.

array array elements




Definition

, . , , , . ? . , , , . . :

  • M(i), - , . i - . i- .

. , i integer. PHP -. i - , , , - array ("bar"). .





array elements




. - , , . .

  • " ". , . , , .
  • "". -. , , .

, , , , .

, . , . . , .

php array element




  1. . "", "i", , "", "R", .
  2. "" .
  3. . .
  4. i=1, R=0.
  5. . . . . - Pascal.

repeat





R=R+M[i];

i=i+1;

until i>k

? "repeat". , , . ( ). "until" , . 5 (=5), [6] , .

, . :

if () then ( ) else (, );

sum of array elements




: " , , ". "". .

? , , , . - . ++.

  • , , , . . "i=0". , .

while (i<=k)

{

i=i+1; // i +=1;

if (R <= M[i])

{

R=M[i]

}

}

maximum array element




, , . ? i<=, , [1] "R". "R" , , . , , .

PHP

. , , , . , ?

. . (, ), , ... , , .

PHP - . . , , , . , , .

number of array elements




? - , . , . . , - , . . , . . , , .




All Articles