human
What is a code to find Array obtained after adding terms of AP for Q queries and the other steps required given the following:
Find Array obtained after adding terms of AP for Q queries | Function to find array after performing the given query to the array elements.
Traverse the given query.
Traverse the given array.
Update the value of A [ i ].
Update the value of curr.
Print the array elements.
Driver Code.
Function Call"
Solution in Python:
assistant
#Here is code to find Array obtained after adding terms of AP for Q queries and the other steps required.
 def addAP ( A , Q , operations ) :
	for L , R , a , d in operations :
		curr = a
		for i in range ( L - 1 , R ) :
			A [ i ] += curr
			curr += d
	for i in A :
		print ( i , end = ' ▁ ' )
A = [ 5 , 4 , 2 , 8 ]
Q = 2
Query = [ ( 1 , 2 , 1 , 3 ) , ( 1 , 4 , 4 , 1 ) ]
addAP ( A , Q , Query )