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 | Arrays, their initialization, garbage collection were explained well... | 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?` | Although a-2 is not the address of an array element, it is possible to access it (at least there is no prohibition). Although we do not have the right to do this because it is someone else's memory area. | 1.4/1.5 |
3) Can an array have two dimensions? | 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!!!_ | The size of the array for the divisors is not the main thing in this problem. The main thing is that you explained why you should search for the root of 2. It seems that the check in line 26 is superfluous (one of them). And it would be worth thinking about how to arrange the resulting divisors. Not sort - but arrange!) | 1.9/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` | The array size should have been stored in the variable n=55 to make it easier to change this parameter in the future. | 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 is true that you demonstrated both the input and output arrays. | 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. | You explained your understanding of the "two largest", and almost correctly solved the problem. But you should always strive for efficiency, universality, perfection. At first I thought that your program would not react to identical numbers, but here it does them well. However, if all the numbers are, for example, `-3` - it will give the wrong result. Think about this point | 1.8/2 |
Total: | 😀 | 9.6/10 |
RE: SLC21 Week2 - Programming Arrays
You are viewing a single comment's thread from:
SLC21 Week2 - Programming Arrays
Thank you for the detailed back. 😀
2- Yes, I have mentioned a-2 is an invalid address for our array. I have accessed it to explain its invalidity.
4- I needed to avoid adding the number itself and repeating divisors, hence the checks.
I know, size of array wasn't the main problem here but since "efficiency" was the requirement, I considered it too. I was tempted to arrange the divisors though but skipped deliberately as it wasn't the main problem as well.
7- Umm... how can we get -3? The range is from 102 to 707, that's why I didn't wrote instructions for negative numbers.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
yes I understand it))) but for the task we needed some numbers
and finding the two largest is a separate task that should be independent of the previous one
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hmmm... I didn't interpret it as a separate task.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit