Answered step by step
Verified Expert Solution
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
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 cozy cages. You may assume
there is exactly cat per cozy cage. The first family adopted the cat in cage The second
family adopted the cat in cage The third family adopted the cat in cage 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 in the first week
Adopts on Monday
Adds Lee to the end of the name
Moves cages down
The Second Family
Adopts the cat in position in the first week
Adopts on Tuesday
Adds Lyn to the end of the name
Moves cages down
The Third Family
Adopts the cat in position in the first week
Adopts on Wednesday
Adds Eve to the end of the name
Moves 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 integers, N and K N K 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 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
Steve
CrunchyCatLuna
PrincessHoneybelle
Bruce
TippyToe
Ili
SteveLeeEve
CrunchyCatLunaLynEve
PrincessHoneybelleEve
Bruce
No cat found.
No cat found.
Midna
Chloe
KhaleesiCat
Megan
RubyTheBabyCat
No cat found.
No cat found.
No cat found.
Megan
RubyTheBabyCat
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
In the first case there are cats, and we will let the cats be adopted for 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 Here
with
cat
Family Here
with
cat
Family 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 Let the cats come back at the beginning of the week. The st
foster family arrives and drops off Steve now called SteveLee They move over 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 Here
with no
cat
Family Here
with
cat
Family Here
with
cat
The nd family arrives and drops off CrunchyCatLuna now called CrunchyCatLunaLyn They
move over places and try to adopt TippyToe, AND they succeed!!!
Cat SteveLee CrunchyCa
tLunaLyn
PrincessH
oneyBelle
Bruce TippyToe Ili
Family Here
with no
cat
Family Here
with
cat
Family Here
with
cat
The rd family arrives and drops off PrincessHoneyBelle now called PrincessHoneyBelleEve
They move over 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
Cat SteveLee CrunchyCa
tLunaLyn
PrincessH
oneyBelle
Bruce TippyToe Ili
Family Here
with no
cat
Family Here
with
cat
Family Here
with
cat
At the end of week we have the following,
Cat SteveLee CrunchyCa
tLunaLynE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started