C Programming Language Note: Input and Output must be the same use C Language only
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
Related questions
Question
100%
C
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5f22aa43-03d6-46b5-b728-a5e8e0bcb567%2Fbab54483-d34a-4502-a79c-86fb7b6ba57a%2Fudezoob_processed.png&w=3840&q=75)
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5f22aa43-03d6-46b5-b728-a5e8e0bcb567%2Fbab54483-d34a-4502-a79c-86fb7b6ba57a%2Fnlllybn_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education