Write a program using the storage of a sequence of numbers in the computer's memory (count the number of numbers in the sequence known). Use the for statement. Given the real numbers a1, ... a30 . Get: max (a1 + a30, a2 + a29, ..., a15 + a16)
- And the label server? What programming language? - SoftR
- The answer is in the comments to the answer given by @Dem. In max, place a1 + a30 . In the loop, go from a2 to the middle, calculating the sum of the "extremes". - avp
|
2 answers
It is very simple. Create an array of 15 elements b, and then loop from 1 to 15, b[i] = a [i] + a [30-i + 1] . Next, you need to find the maximum in b.
|
max = -1; for(i = 0; i < 10; i++){ if(arr[i] > max){ max = arr[i]; } } The logic of this, and then redo it under the desired language.
- Better max = arr [0]; for (i = 1; .... - avp
- Not fundamentally, the essence does not change - Dem
- oneEssentially, because real numbers in question - avp
|