C Programming Language Note: Input and Output must be the same  use C Language only

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%

C Programming Language

Note:

Input and Output must be the same 

use C Language only

Learning Outcomes:
LO 2 : Apply syntax and functions in C language in problem solving
LO 3 : Construct a program using C language in problem solving
LO 4 : Design a program with file processing using C language in problem solving
LO 5: Choose the best sorting and searching algorithm in problem solving
I. Studi Kasus (100%)
At Lili's birthday party, there was a game arranged by Jojo as the host. That game is to distribute a
certain amount of candy to X number of people where all the candy tastes sweet except for one last
candy which tasted like rotten nuts. candy distribution will sequentially starting from position Z and if it
passes the last position then the round continues to the first position. The person in which position
will get the last candy.
Format Input
The first line of input a is T, which is the number of test
cases. The second row and the next row T number is 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.
Format Output
A string "Case # N: “ and a number representing the position of the person who got the last candy
Page 1 of 5
Transcribed Image Text:Learning Outcomes: LO 2 : Apply syntax and functions in C language in problem solving LO 3 : Construct a program using C language in problem solving LO 4 : Design a program with file processing using C language in problem solving LO 5: Choose the best sorting and searching algorithm in problem solving I. Studi Kasus (100%) At Lili's birthday party, there was a game arranged by Jojo as the host. That game is to distribute a certain amount of candy to X number of people where all the candy tastes sweet except for one last candy which tasted like rotten nuts. candy distribution will sequentially starting from position Z and if it passes the last position then the round continues to the first position. The person in which position will get the last candy. Format Input The first line of input a is T, which is the number of test cases. The second row and the next row T number is 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. Format Output A string "Case # N: “ and a number representing the position of the person who got the last candy Page 1 of 5
Constraints
1<T< 100
1< X,Y < 10³
1<Z< X
Sample Input
Sample Output
4
Case #1: 1
3 4 1
Case #2: 3
3 5 2
Case #3: 3
4 2 2
4 5 2
Case #4: 2
Sample Input
Sample Output
2
Case #1: 6
Case #2: 3
7 19 2
3 7 3
In the sample above, the example inputted in the case:
34 1 means there are 3 people who will be distributed candy, there are 4 candies, starting to be
divided from the 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 the last candy
is
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.
Notes
Even though it wasn't stated in the problem, you should now know that extra spaces or lines are
considered WRONG ANSWER.
Transcribed Image Text:Constraints 1<T< 100 1< X,Y < 10³ 1<Z< X Sample Input Sample Output 4 Case #1: 1 3 4 1 Case #2: 3 3 5 2 Case #3: 3 4 2 2 4 5 2 Case #4: 2 Sample Input Sample Output 2 Case #1: 6 Case #2: 3 7 19 2 3 7 3 In the sample above, the example inputted in the case: 34 1 means there are 3 people who will be distributed candy, there are 4 candies, starting to be divided from the 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 the last candy is 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. Notes Even though it wasn't stated in the problem, you should now know that extra spaces or lines are considered WRONG ANSWER.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
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