Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Foster Home Objective Give practice with reading and writing to standard input in C . Give practice with loops and conditionals in C . Give

Foster Home
Objective
Give practice with reading and writing to standard input in C.
Give practice with loops and conditionals in C.
Give practice with functions in C.
Give practice with strings in C.
Story
You have recently been hired to help out with Kaylee and Trans (KaT) Pet Shop. There are 3
foster homes that help take care of cats. Every week they take in a cat. When the week is over,
they bring the cat back, but the home leaves their mark by adding a signature suffix to the name
of the cat.
The cats to adopt are arranged in a row of N, which is at least 3, cozy cages. You may assume
there is exactly 1 cat per cozy cage. The first family adopted the cat in cage 1. The second
family adopted the cat in cage 2. The third family adopted the cat in cage 3. After they bring
their cat back they will adopt a new cat. The foster families typically want to adopt a different cat
for the week so they will move over some number of positions in the list of cages and adopt the
cat in that location. If there is no cat in that cage that week, the family will go catless for the
week (), remain at that position, and then resume counting from that position in the following
week. If they reach the last cage when counting, they move back to the first cage and resume
counting from there.
We know the following about the three foster homes,
The First Family
Adopts the cat in position 1 in the first week
Adopts on Monday
Adds Lee to the end of the name
Moves 2 cages down
The Second Family
Adopts the cat in position 2 in the first week
Adopts on Tuesday
Adds Lyn to the end of the name
Moves 3 cages down
The Third Family
Adopts the cat in position 3 in the first week
Adopts on Wednesday
Adds Eve to the end of the name
Moves 5 cages down
You are pretty sure that none of the original cats have been adopted. These families have been
adopting cats for some time now, and you want to know what are the current cats available for
adoption.
Problem
Given the initial cages and the number of weeks the adoption has occurred determine the
names of the cats present on the Friday of that week.
Input
The first line of input will contain 2 integers, N and K,(3<= N <=500,1<= K <=500) representing
the number of cozy cages and the number of weeks of which the adoption process has
occurred, respectively.
The following N lines will each contain a single string of up to 19 characters representing the
original name of the cat.
Output
Output N lines each containing the current name of the cat in the cozy cage at the end of the K
weeks. If no cat is present print No cat found. instead.
Sample Input Sample Output
64
Steve
CrunchyCatLuna
PrincessHoneybelle
Bruce
TippyToe
Ili
SteveLeeEve
CrunchyCatLunaLynEve
PrincessHoneybelleEve
Bruce
No cat found.
No cat found.
51
Midna
Chloe
KhaleesiCat
Megan
RubyTheBabyCat
No cat found.
No cat found.
No cat found.
Megan
RubyTheBabyCat
86
Moosh
Liz
Alligator
Preppy
LAPOCHKA
jimothy
toebeans
arson
No cat found.
LizLynEve
No cat found.
No cat found.
LAPOCHKALynEve
jimothyLyn
toebeansLeeEve
arsonEve
Sample Explanation
FOR CASE 1
In the first case there are 6 cats, and we will let the cats be adopted for 4 weeks total. Below is
an table representing the situation at the end of the first week,
Cat Steve CrunchyCa
tLuna
PrincessH
oneyBelle
Bruce TippyToe Ili
Family 1 Here
(with
cat)
Family 2 Here
(with
cat)
Family 3 Here
(with
cat)
If we printed the list now we would have
No cat found.
No cat found.
No cat found.
Bruce
TippyToe
Ili
But we need to reach week 4! Let the cats come back at the beginning of the week. The 1st
foster family arrives and drops off Steve (now called SteveLee). They move over 2 places and
try to adopt PrincessHoneyBelle, BUT that cat is not at that location, so the first foster family
goes catless for this week.
Cat SteveLee CrunchyCa
tLuna
PrincessH
oneyBelle
Bruce TippyToe Ili
Family 1 Here
(with no
cat)
Family 2 Here
(with
cat)
Family 3 Here
(with
cat)
The 2nd family arrives and drops off CrunchyCatLuna (now called CrunchyCatLunaLyn). They
move over 3 places and try to adopt TippyToe, AND they succeed!!!
Cat SteveLee CrunchyCa
tLunaLyn
PrincessH
oneyBelle
Bruce TippyToe Ili
Family 1 Here
(with no
cat)
Family 2 Here
(with
cat)
Family 3 Here
(with
cat)
The 3rd family arrives and drops off PrincessHoneyBelle (now called PrincessHoneyBelleEve).
They move over 5 places, but they move past Ili and have to wrap back around. They end up at
the cozy cage with CruchCatLunaLyn. They are able to successfully adopt. The following table
is the result of the end of week 3,
Cat SteveLee CrunchyCa
tLunaLyn
PrincessH
oneyBelle
Bruce TippyToe Ili
Family 1 Here
(with no
cat)
Family 2 Here
(with
cat)
Family 3 Here
(with
cat)
At the end of week 3 we have the following,
Cat SteveLee CrunchyCa
tLunaLynE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago