Can anyone write next() function? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
0

# Can anyone write next() function?

Blurred list Given is a set A with elements of integers greater than 0. In addition, we have two constants m and v greater than 0. We define a new set B with the following rule: the integer x belongs to the set B exactly when at most m is lesser than and for v greater than some element of the set A. In other words, B contains, in addition to each element of the set A, the previous m and the following v integers. We do not know the size of the set A, we access it with the next () function, which we write ourselves. With each call, it returns one element of set A. When it reaches the end of the set, it returns -1. The function prints out the elements of set B in real time before reading the next element of set A should write all those elements of set B that we assume belong to this set. Example: int m=2, v=1; A={1,3,4,9}; Than B={-1,0,1,2,3,4,5,6,7,8,9,10}; https://code.sololearn.com/cTVd3bMegojk/?ref=app

24th Aug 2021, 7:31 AM
TeaserCode
2 Antworten
0
Where is this problem statement from?
24th Aug 2021, 1:33 PM
bernborgess
0
Can you solve it? I don't know how to iterate through the loop to visit every element.
24th Aug 2021, 2:04 PM
TeaserCode