Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # If you wish you can import any modules from the standard library
- # Do not use modules that are not in the standard library
- import sys
- def processArray(array):
- '''Modify this function to process `array` as indicated
- in the question. At the end, return the appropriate
- value.
- Please create appropriate classes, and use appropriate
- data structures as necessary.
- Do not print anything in this function.
- Submit this entire program (not just this function)
- as your answer
- '''
- i = 0
- k = 0
- while i < len(array):
- if array[i] >= 100:
- array[k] = array[i]
- i += 1
- k += 1
- else:
- s = 0
- while i < len(array) and array[i] < 100:
- s += array[i]
- i+=1
- array[k] = s
- k += 1
- return k # change this appropriately, if necessary
- def run():
- array = []
- for line in sys.stdin:
- intval = int(line)
- if intval < 0:
- break
- array.append(intval)
- newlen = processArray(array)
- for i in range(newlen):
- print(array[i])
- if __name__ == '__main__':
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement