Task | Comment | Grade |
---|---|---|
1) Declare an array of any type: explain how to use an array, how to access array elements.Assign values to some of its elements, and use those values display) What are the advantages of an array over ordinary variables | ok | 1.5/1.5 |
2) What is **the name** of the array? What will happen if you display this value on the screen? What does `cout<<a+2;`that mean (cout<<a-2;)? If `cout<<a;` displays 4,000, then how much will it be`a+1?` | There is nothing dangerous in `cout<<a-2;`, it is not `*(a-2)` or `a[-2]`, a is just a number, and you can do addition and subtraction operations with a number. The danger will be (and not always) only when accessing a memory cell with the address (a-2) | 1.4/1.5 |
3) Can an array have two dimensions? | Here I wanted to ask about two `size` and it turned out two `dimensions` And why are all the answers one-dimensional arrays of 5 elements, and two-dimensional 3x4 - some kind of magic))) or psychology?)) | 1/1 |
4) Write a random number in the variable k. `int k=(rand()%101) * (rand()%101) * (rand()%101)+500;` Try to solve the task of finding divisors from the last lesson more efficiently (so that the divisors are found faster) and write the results (not on the screen) but in an array. _Since the transfer of arrays to a function is not a simple topic - filling the array should not be done in the form of a function!!!_ | In the case of a dynamic array, it is worth pre-calculating the total number of divisors. But this could also be done through int div[n]; where n is the pre-calculated number of such divisors. It is not obvious to most people why one should search up to sqrt(k), and not up to k or up to k/2, as most people answered in the last lesson. - then it should have been explained in detail - why the search should be carried out up to sqrt(k). It would have been worth ordering the array of divisors, not sorting it - but ordering it | 1.1/2 |
5) Fill the array with 55 numbers with random numbers from 10 to 50. If there is a number 37 among the elements of the array, print it `yes`, and if there is no such number, print it `no` | ok | 1/1 |
6) Fill an array of 66 numbers with random numbers from 12 to 60. Replace even elements with 7 and odd elements with 77 | It's a good idea to print both the input array and the result of the work at the same time. | 1/1 |
7) Fill the array of 77 numbers with random numbers from 102 to 707. Find the two largest numbers. But the phrase "the two largest numbers" can have many interpretations. Therefore, first explain well how this phrase was understood. And then solve the problem. | Searching through a single array loop is good, but putting -1 in two variables for the maximum numbers is not entirely correct. What if the numbers are all the same? What if the numbers are less than -5, or simply equal to -5. The code should be written universal, efficient, perfect)) | 1.3/2 |
Total: | 8.3/10 |
RE: SLC21 Week2 - Programming arrays
You are viewing a single comment's thread from:
SLC21 Week2 - Programming arrays