Apple and Orange
Sam's house has an apple tree and an orange tree that yield an abundance of fruit. Using the information given below, determine the number of apples and oranges that land on Sam's house. In the diagram below:
Given the value of d for m apples and oranges, determine how many apples and oranges will fall on Sam's house (i.e., in the inclusive range [s, t] )? For example, Sam's house is between s = 7 t = 10. The apple tree is located at a = 4 and the orange at b = 12. There are m = 3 apples and n = 3 oranges. Apples are thrown, apples = [2, 3, 4] units distance from a, and oranges = [3, 2, 4] units distance. Adding each apple distance to the position of the tree, they land at [4 + 2, 4 + 3, 4 + 4] = [6, 7, 0]. Oranges land at [12 + 3, 12 + 2, 12 + 4] = [15, 10, 8]. One apple and two oranges land in the inclusive range 7  10 so we print Function Description极好笔卸2nd更加被磨练了的技术期望的第2子弹Complete the countApplesAndOranges function in the editor below. It should print the number of apples and oranges that land on Sam's house, each on a separate line. countApplesAndOranges has the following parameter(s):
Input Format The first line contains two spaceseparated integers denoting the respective values of s and t. The second line contains two spaceseparated integers denoting the respective values of a and b. The third line contains two spaceseparated integers denoting the respective values of m and n. The fourth line contains spaceseparated integers denoting the respective distances that each apple falls from point a. The fifth line contains n spaceseparated integers denoting the respective distances that each orange falls from point b. Constraints
Output Format Print two integers on two different lines:
Sample Input 0 Sample Output 0 1 1 Explanation 0 The first apple falls at position 5  2 = 3. The second apple falls at position 5 + 2 = 7. The third apple falls at position 5 + 1 = 6. The first orange falls at position15 + 5 = 20. The second orange falls at position 15  6 = 9. Only one fruit (the second apple) falls within the region between 7 and 11, so we print 1 as our first line of output. Only the second orange falls within the region between 7 and 11, so we print as our second line of output. The Code OF Apple and Orange Problem in CExplanation of above code: 1. Declared variable s, t, b, a, m, n, d 2. Declared and initialized variable apple = 0; and orange = 0 3. Asked to insert value of start & end point of boundary of Sam's house 4. Asked to insert value of apple & orange tree location 5. Asked to insert value for no. of apples & no. of oranges 6. Loop for entering distance of m apples is given below: Let starting point s = 7 and end point t = 11 of Sam's House, location of apple tree a = 5 and orange tree b = 15, and no. of apples m = 3 and no. of oranges n = 2. Hence above for loop run for m = 3, Let value entered are [2 2 1], 7. Loop for entering distance of n oranges is below As we already look, starting point s = 7 and end point t = 11 of Sam's House, location of apple tree a = 5 and orange tree b = 15, and no. of apples m = 3 and no. of oranges n = 2. Hence above for loop run for n = 2, Let value entered are [5, 6], 8. At last line the statement printf( " %d %d ", apple, orange); It will print values of apple and oranges which actually fell on or inside the boundary of Sam's house, since value of apple =1 and orange = 1, therefore output will be: 1 1
Next TopicHigh Availability

AI
AWS
Selenium
Cloud
Hadoop
ReactJS
D. Science
Angular 7
Blockchain
Git
ML
DevOps