Professional Documents
Culture Documents
Introduction To C Programming and Data Structures 4Th Edition Liang Solutions Manual Full Chapter PDF
Introduction To C Programming and Data Structures 4Th Edition Liang Solutions Manual Full Chapter PDF
Problem Description:
A school has 100 lockers and 100 students. All lockers are closed on the first day of
school. As the students enter, the first student, denoted S1, opens every locker. Then the
second student, S2, begins with the second locker, denoted L2, and closes every other
locker. Student S3 begins with the third locker and changes every third locker (closes it if
it was open, and opens it if it was closed). Student S4 begins with locker L4 and changes
every fourth locker. Student S5 starts with L5 and changes every fifth locker, and so on,
until student S100 changes L100.
After all the students have passed through the building and changed the lockers, which
lockers are open? Write a program to find your answer.
(Hint: Use an array of 100 Boolean elements, each of which indicates whether a locker is
open (true) or closed (false). Initially, all lockers are closed.)
Analysis:
(Describe the problem including input and output in your own words.)
Design:
(Describe the major steps for solving the problem.)
1
Coding: (Copy and Paste Source Code here. Format your code using Courier 10pts)
1. Print this Word file and Submit to me before the class on the due day
2. Compile, Run, and Submit to LiveLab as Exercise7_15 (you must submit the program
regardless whether it complete or incomplete, correct or incorrect)
Solution:
#include <iostream>
using namespace std;
int main()
{
// Declare a constant value for the number of lockers
const int NUMBER_OF_LOCKER = 100;
return 0;
}
3
Another random document with
no related content on Scribd:
expenses, including legal fees. YOU AGREE THAT YOU HAVE NO
REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF
WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE
PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE
FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.
1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.