WRITE CODE IN C LANGUANGE At Lili's birthday party, there was a game arranged by Jojo as the host. That game is to distribute Y number of candy to X number of people where all the candy tastes sweet except for one last candy which tasted like rotten nuts. Candy distribu- tion will be sequentially starting from position Z and if past the last position then the distribution of candy continues to the first position. Write down the person in which position will get the last candy. Input Format The first line of input is T, which is the number of test cases. The second row and the next number of T rows are X, Y, Z. X is the number of people to whom the candy will be distributed. Y is the number of candy available. Z is the starting position of the person to whom the candy will be distributed. Output Format A string "Case #N: " and a number representing the position of the person who got the last candy Constraints 1ST< 100 1s X, Y s 103 1sZsX Sample Input Sample Output Case 1: 1 Case 12: 3 3 4 1 35 2 4 22 452 Case #3: 3 Case 4: 2 Sample Input Sample Output Case #1: 6 7 19 2 37 3 Case #2: 3 In the sample above, the example inputted in the case: 341 means there are 3 people who will be distributed candy, there are 4 candies, starting to be divided from 1st person. So that the 1st, 2nd, 3rd person will each get one candy then return to 1st person gets the last candy. Then output 1. 422 means that there are 4 people who will be distributed candy, there are 2 candies, starting to be divided from the 2nd person. So the 2nd, 3rd person will each get 1 candy where is the last candy obtained by the 3rd person. 452 means that the candy distribution order is from the 2nd, 3rd, 4th, 1st, 2nd person to the last person who getting candy is 2nd person, then 2nd output.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Answer in C languange

WRITE CODE IN C LANGUANGE
At Lili's birthday party, there was a game arranged by Jojo as the host. That game is to distribute Y number of candy to X
number of people where all the candy tastes sweet except for one last candy which tasted like rotten nuts. Candy distribu-
tion will be sequentially starting from position Z and if past the last position then the distribution of candy continues to the
first position. Write down the person in which position will get the last candy.
Input Format
The first line of input is T, which is the number of test cases.
The second row and the next number of T rows are X, Y, Z.
X is the number of people to whom the candy will be distributed.
Y is the number of candy available.
Z is the starting position of the person to whom the candy will be distributed.
Output Format
A string "Case #N: " and a number representing the position of the person who got the last candy
Constraints
1<T< 100
1< X, Y < 103
1<Z <X
Sample Input
Sample Output
Case #1: 1
Case #2: 3
3 41
352
Case #3: 3
Case #4: 2
4 2 2
45 2
Sample Input
Sample Output
Case #1: 6
7 19 2
37 3
Case #2: 3
In the sample above, the example inputted in the case:
341 means there are 3 people who will be distributed candy, there are 4 candies, starting to be divided from 1st person. So
that the 1st, 2nd, 3rd person will each get one candy then return to 1st person gets the last candy. Then output 1.
422 means that there are 4 people who will be distributed candy, there are 2 candies, starting to be divided from the 2nd
person. So the 2nd, 3rd person will each get 1 candy where is the last candy obtained by the 3rd person.
452 means that the candy distribution order is from the 2nd, 3rd, 4th, 1st, 2nd person to the last person who getting candy
is 2nd person, then 2nd output.
Transcribed Image Text:WRITE CODE IN C LANGUANGE At Lili's birthday party, there was a game arranged by Jojo as the host. That game is to distribute Y number of candy to X number of people where all the candy tastes sweet except for one last candy which tasted like rotten nuts. Candy distribu- tion will be sequentially starting from position Z and if past the last position then the distribution of candy continues to the first position. Write down the person in which position will get the last candy. Input Format The first line of input is T, which is the number of test cases. The second row and the next number of T rows are X, Y, Z. X is the number of people to whom the candy will be distributed. Y is the number of candy available. Z is the starting position of the person to whom the candy will be distributed. Output Format A string "Case #N: " and a number representing the position of the person who got the last candy Constraints 1<T< 100 1< X, Y < 103 1<Z <X Sample Input Sample Output Case #1: 1 Case #2: 3 3 41 352 Case #3: 3 Case #4: 2 4 2 2 45 2 Sample Input Sample Output Case #1: 6 7 19 2 37 3 Case #2: 3 In the sample above, the example inputted in the case: 341 means there are 3 people who will be distributed candy, there are 4 candies, starting to be divided from 1st person. So that the 1st, 2nd, 3rd person will each get one candy then return to 1st person gets the last candy. Then output 1. 422 means that there are 4 people who will be distributed candy, there are 2 candies, starting to be divided from the 2nd person. So the 2nd, 3rd person will each get 1 candy where is the last candy obtained by the 3rd person. 452 means that the candy distribution order is from the 2nd, 3rd, 4th, 1st, 2nd person to the last person who getting candy is 2nd person, then 2nd output.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education