SlideShare a Scribd company logo
1 of 4
Download to read offline
Assigned: April 9, 2014 1 Due: May 4, 2014
HW 7: More Arrays, Strings, Vec-
tors, and Pointers
COMP 3010
Assigned on: April 9, 2014 Due on: May 4, 2014
Problem 1 Write a program to assign passengers seats in an airplane. Assume a small
airplane with seat numbering as follows:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D
The program should display the seat pattern, with an X marking the seats already
assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like
this:
1 X B C D
2 A X C D
3 A B C D
4 A B X D
5 A B C D
6 A B C D
7 A B C D
After displaying the seats available, the program prompts for the seat desired, the user
types in a seat, and then the display of available seats is updated. This continues until
all seats are filled or until the user signals that the program should end. If the user types
in a seat that is already assigned, the program should say that that seat is occupied and
ask for another choice.
Problem 2 The mathematician John Horton Conway invented the “Game of Life.” Though
not a “game” in any traditional sense, it provides interesting behavior that is specified
with only a few rules. This project asks you to write a program that allows you to specify
an initial configuration. The program follows the rules of LIFE to show the continuing
behavior of the configuration.
LIFE is an organism that lives in a discrete, two-dimensional world. While this world is
actually unlimited, We don’t have that luxury, so we restrict the array to 80 characters
HW 7: More Arrays, Strings, Vectors, and Pointers
Assigned: April 9, 2014 2 Due: May 4, 2014
wide by 22 character positions high. If you have access to a larger screen, by all means
use it. This world is an array with each cell capable of holding one LIFE cell. Genera-
tions mark the passing of time. Each generation brings births and deaths to the LIFE
continuity. The births and deaths follow the following set of rules.
We define each cell to have eight neighbor cells. The neighbors of a cell are the cells
directly above, below, to the right, to the left, diagonally above to the right and left, and
diagonally below to the right and left. If an occupied cell has zero or one neighbors, it dies
of loneliness. If an occupied cell has more than three neighbors, it dies of overcrowding.
If an empty cell has exactly three occupied neighbor cells, there is a birth of a new cell
to replace the empty cell. Births and deaths are instantaneous and occur at the changes
of generation. A cell dying for whatever reason may help cause birth, but a newborn cell
cannot resurrect a cell that is dying, nor will a cell’s death prevent the death of another,
say, by reducing the local population.
Notes: Some configurations grow from relatively small starting configurations. Others
move across the region. It is recommended that for text output you use a rectangular
array of char with 80 columns and 22 rows to store the LIFE world’s successive genera-
tions. Use an asterisk * to indicate a living cell, and use a blank to indicate an empty
(or dead) cell. If you have a screen with more rows than that, by all means make use of
the whole screen.
Examples:
***
becomes
*
*
*
then becomes
***
again. and so on.
Suggestions: Look for stable configurations. That is, look for communities that repeat
patterns continually. The number of configurations in the repetition is called the period.
There are configurations that are fixed, which continue without change. A possible project
is to find such configurations. Hints: Define a void function named generation that takes
the array we call world, an 80 column by 22 row array of char, which contains the initial
configuration. The function scans the array and modifies the cells, marking the cells with
births and deaths in accord with the rules listed earlier. This involves examining each
cell in turn, either killing the cell, letting it live, or, if the cell is empty, deciding whether
a cell should be born. There should be a function display that accepts the array world
HW 7: More Arrays, Strings, Vectors, and Pointers
Assigned: April 9, 2014 3 Due: May 4, 2014
and displays the array on the screen. Some sort of time delay is appropriate between
calls to generation and display. To do this, your program should generate and display
the next generation when you press Return. You are at liberty to automate this, but
automation is not necessary for the program.
Problem 3 Write a program that inputs two string variables, first and last, each of which
the user should enter with his or her name. First, convert both strings to all lowercase.
Your program should then create a new string that contains the full name in pig latin
with the first letter capitalized for the first and last name. The rules to convert a word
into pig latin are as follows:
(a) If the first letter is a consonant move it to the end and add “ay” to the end.
(b) If the first letter is a vowel, add “way” to the end.
For example, if the user inputs “Erin” for the first name and “Jones” for the last name,
then the program should create a new stnng with the text “Erinway Onesjay” and print
it.
Problem 4 You run four computer labs. Each lab comains computer stations that are
numbered as shown in the table below:
Lab Number Computer Station Numbers
1 1 – 5
2 1 – 6
1 1 – 4
1 1 – 3
Each user has a unique five-digit ID number. Whenever a user logs on, the user’s ID, lab
number, and the computer station number are transmitted to your system. For example,
if user 49193 logs onto station 2 in lab 3, then your system receives (49193, 2, 3) as
input data. Similarly, when a user logs off a station, then your system receives the lab
number and computer station number. Write a computer program that could be used to
track, by lab, which user is logged onto which computer. For exarnple, if user 49193 is
logged into station 2 in lab 3 and user 99577 is logged into station 1 of lab 4 then your
system might display the following:
Lab Number Computer Stations
1 1: empty 2: empty 3: empty 4: empty 5: empty
2 1: empty 2; empty 3: empty 4: empty 5: empty 6:empty
3 1: empty 2: 49193 3: empty 4: empty
4 1: 99577 2: empty 3: empty
Create a menu that allows the administrator to simulate the transmission of information
by manually typing in the login or logoff data. Whenever someone logs in or out, the
HW 7: More Arrays, Strings, Vectors, and Pointers
Assigned: April 9, 2014 4 Due: May 4, 2014
display should be updated. Also write a search option so that the administrator can type
in a user ID and the system will output what lab and station number that user is logged
into, or “None” if the user ID is not logged into any computer station. You should use
a fixed array of length 4 for the labs. Each array entry points to a dynamic array that
stores the user login information for each respective computer station. The structure is
shown in the figure below. This structure is sometimes called a ragged array since the
columns are of unequal length.
Lab Array Dynamic Arrays for Computer Stations
Problem 5 One problem with dynamic arrays is that once the array is created using the
new operator the size cannot be changed. For example, you might want to add or delete
entries from the array as you can with a vector. This project asks you to create functions
that use dynamic arrays to emulate the behavior of a vector.
First, write a program that creates a dynamic array of five strings. Store five names of
your choice into the dynamic array. Next, complete the following two functions:
string* addEntry(string *dynamicArray, int &size, string newEntry); This func-
tion should create a new dynamic array one element larger than dynamtcArray, copy all
elements from dynamicArray into the new array, add the new entry onto the end of the
new array, increment size, delete dynamicArray, and return the new dynamic array.
string* deleteEntry(string *dynamicArray, int &size, string entryToDelete);
This function should search dynamicArray for entryToDelete. If not found, the request
should be ignored and the unmodified dynamtcArray returned. If found, create a new
dynamic array one element smaller than dynamicArray. Copy all elements except en-
tryToDelete into the new array, delete dynamicArray, decrement size, and and return
the new dynamic array.
Test your functions by adding and deleting several names to the array while outputting
the contents of the array. You will have to assign. the array returned by addEntry or
deleteEntry back to the dynamic array variable in your main function.

More Related Content

What's hot

Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & ImportMohd Sajjad
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONvikram mahendra
 
C programming session 11
C programming session 11C programming session 11
C programming session 11Dushmanta Nath
 
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...
OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...hwbloom39
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityMohd Sajjad
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3Syed Farjad Zia Zaidi
 
Lecture no 1
Lecture no 1Lecture no 1
Lecture no 1hasi071
 
Learning R while exploring statistics
Learning R while exploring statisticsLearning R while exploring statistics
Learning R while exploring statisticsDorothy Bishop
 
Practical java
Practical javaPractical java
Practical javanirmit
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basicsrobertbenard
 
Notes2
Notes2Notes2
Notes2hccit
 
Programming basics
Programming basicsProgramming basics
Programming basicsillidari
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| FundamentalsMohd Sajjad
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic Manzoor ALam
 

What's hot (16)

Python-02| Input, Output & Import
Python-02| Input, Output & ImportPython-02| Input, Output & Import
Python-02| Input, Output & Import
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
 
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...
OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutability
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Lecture no 1
Lecture no 1Lecture no 1
Lecture no 1
 
Learning R while exploring statistics
Learning R while exploring statisticsLearning R while exploring statistics
Learning R while exploring statistics
 
Practical java
Practical javaPractical java
Practical java
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Notes2
Notes2Notes2
Notes2
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
Computer
ComputerComputer
Computer
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 

Viewers also liked

Comp 3010 Syllabus
Comp 3010 SyllabusComp 3010 Syllabus
Comp 3010 Syllabusenidcruz
 
My First Source Code
My First Source CodeMy First Source Code
My First Source Codeenidcruz
 
Lab 1: Compiler Toolchain
Lab 1: Compiler ToolchainLab 1: Compiler Toolchain
Lab 1: Compiler Toolchainenidcruz
 
Platform Building for Influencers
Platform Building for InfluencersPlatform Building for Influencers
Platform Building for InfluencersCadence PR
 
El sav
El savEl sav
El savsena
 
My last vacation
My last vacationMy last vacation
My last vacationcejeroca
 
minimally invasive percutaneous plate osteosynthesis
minimally invasive percutaneous plate osteosynthesisminimally invasive percutaneous plate osteosynthesis
minimally invasive percutaneous plate osteosynthesisSagar Tomar
 
Morfología de la Lesión y Muerte Celular
Morfología de la Lesión y Muerte CelularMorfología de la Lesión y Muerte Celular
Morfología de la Lesión y Muerte CelularAbraham Luna Ayala
 
Segmentacion de mercados guiovanni quijano
Segmentacion de mercados guiovanni quijanoSegmentacion de mercados guiovanni quijano
Segmentacion de mercados guiovanni quijanoGuiovanni Quijano
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arraysenidcruz
 

Viewers also liked (20)

Comp 3010 Syllabus
Comp 3010 SyllabusComp 3010 Syllabus
Comp 3010 Syllabus
 
My First Source Code
My First Source CodeMy First Source Code
My First Source Code
 
Lab 1: Compiler Toolchain
Lab 1: Compiler ToolchainLab 1: Compiler Toolchain
Lab 1: Compiler Toolchain
 
POSTER REMAKE
POSTER REMAKEPOSTER REMAKE
POSTER REMAKE
 
Platform Building for Influencers
Platform Building for InfluencersPlatform Building for Influencers
Platform Building for Influencers
 
latest resume
latest resumelatest resume
latest resume
 
Ruzannik
RuzannikRuzannik
Ruzannik
 
El sav
El savEl sav
El sav
 
Presentacion
PresentacionPresentacion
Presentacion
 
tesla
teslatesla
tesla
 
4º basico a 27 de noviembre
4º basico a  27 de noviembre4º basico a  27 de noviembre
4º basico a 27 de noviembre
 
Tekno real madrid
Tekno real madridTekno real madrid
Tekno real madrid
 
My last vacation
My last vacationMy last vacation
My last vacation
 
minimally invasive percutaneous plate osteosynthesis
minimally invasive percutaneous plate osteosynthesisminimally invasive percutaneous plate osteosynthesis
minimally invasive percutaneous plate osteosynthesis
 
Morfología de la Lesión y Muerte Celular
Morfología de la Lesión y Muerte CelularMorfología de la Lesión y Muerte Celular
Morfología de la Lesión y Muerte Celular
 
Segmentacion de mercados guiovanni quijano
Segmentacion de mercados guiovanni quijanoSegmentacion de mercados guiovanni quijano
Segmentacion de mercados guiovanni quijano
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
Toys on tour 1
Toys on tour   1Toys on tour   1
Toys on tour 1
 
Osteomyelitis
OsteomyelitisOsteomyelitis
Osteomyelitis
 
Pretérito Indefinido o Simple
Pretérito Indefinido o Simple Pretérito Indefinido o Simple
Pretérito Indefinido o Simple
 

Similar to Lab7: More Arrays, Strings, Vectors, and Pointers

Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02auswhit
 
Lab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docx
Lab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docxLab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docx
Lab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docxABDULAHAD507571
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfleventhalbrad49439
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxjosephineboon366
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docxwilcockiris
 
C++ Loops General Discussion of Loops A loop is a.docx
C++ Loops  General Discussion of Loops A loop is a.docxC++ Loops  General Discussion of Loops A loop is a.docx
C++ Loops General Discussion of Loops A loop is a.docxhumphrieskalyn
 
Md university cmis 102 week 5 hands
Md university cmis 102 week 5 handsMd university cmis 102 week 5 hands
Md university cmis 102 week 5 handseyavagal
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdfMemeMiner
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxpriestmanmable
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addisorayan5ywschuit
 
Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxadihartanto7
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01Drjilesh
 
(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercises(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercisesNico Ludwig
 
spreadsheet program
spreadsheet programspreadsheet program
spreadsheet programsamina khan
 
Ecet 370 Education Organization -- snaptutorial.com
Ecet 370   Education Organization -- snaptutorial.comEcet 370   Education Organization -- snaptutorial.com
Ecet 370 Education Organization -- snaptutorial.comDavisMurphyB81
 
C programming perso notes
C programming perso notesC programming perso notes
C programming perso notesMelanie Tsopze
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)IIUM
 

Similar to Lab7: More Arrays, Strings, Vectors, and Pointers (20)

Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
 
Lab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docx
Lab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docxLab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docx
Lab 4 ,5 & 6 Submission (3) 14136_Mohsin Alvi.docx
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docx
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
A01
A01A01
A01
 
C++ Loops General Discussion of Loops A loop is a.docx
C++ Loops  General Discussion of Loops A loop is a.docxC++ Loops  General Discussion of Loops A loop is a.docx
C++ Loops General Discussion of Loops A loop is a.docx
 
Md university cmis 102 week 5 hands
Md university cmis 102 week 5 handsMd university cmis 102 week 5 hands
Md university cmis 102 week 5 hands
 
Data Structure.pdf
Data Structure.pdfData Structure.pdf
Data Structure.pdf
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addi
 
Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptx
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
 
(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercises(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercises
 
spreadsheet program
spreadsheet programspreadsheet program
spreadsheet program
 
Ecet 370 Education Organization -- snaptutorial.com
Ecet 370   Education Organization -- snaptutorial.comEcet 370   Education Organization -- snaptutorial.com
Ecet 370 Education Organization -- snaptutorial.com
 
C programming perso notes
C programming perso notesC programming perso notes
C programming perso notes
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)
 
Java execise
Java execiseJava execise
Java execise
 

Recently uploaded

TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsSumit Kumar yadav
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptxRajatChauhan518211
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000Sapana Sha
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.Nitya salvi
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)Areesha Ahmad
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfrohankumarsinghrore1
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)Areesha Ahmad
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 

Recently uploaded (20)

TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptx
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 

Lab7: More Arrays, Strings, Vectors, and Pointers

  • 1. Assigned: April 9, 2014 1 Due: May 4, 2014 HW 7: More Arrays, Strings, Vec- tors, and Pointers COMP 3010 Assigned on: April 9, 2014 Due on: May 4, 2014 Problem 1 Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows: 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 A B C D The program should display the seat pattern, with an X marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like this: 1 X B C D 2 A X C D 3 A B C D 4 A B X D 5 A B C D 6 A B C D 7 A B C D After displaying the seats available, the program prompts for the seat desired, the user types in a seat, and then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that that seat is occupied and ask for another choice. Problem 2 The mathematician John Horton Conway invented the “Game of Life.” Though not a “game” in any traditional sense, it provides interesting behavior that is specified with only a few rules. This project asks you to write a program that allows you to specify an initial configuration. The program follows the rules of LIFE to show the continuing behavior of the configuration. LIFE is an organism that lives in a discrete, two-dimensional world. While this world is actually unlimited, We don’t have that luxury, so we restrict the array to 80 characters
  • 2. HW 7: More Arrays, Strings, Vectors, and Pointers Assigned: April 9, 2014 2 Due: May 4, 2014 wide by 22 character positions high. If you have access to a larger screen, by all means use it. This world is an array with each cell capable of holding one LIFE cell. Genera- tions mark the passing of time. Each generation brings births and deaths to the LIFE continuity. The births and deaths follow the following set of rules. We define each cell to have eight neighbor cells. The neighbors of a cell are the cells directly above, below, to the right, to the left, diagonally above to the right and left, and diagonally below to the right and left. If an occupied cell has zero or one neighbors, it dies of loneliness. If an occupied cell has more than three neighbors, it dies of overcrowding. If an empty cell has exactly three occupied neighbor cells, there is a birth of a new cell to replace the empty cell. Births and deaths are instantaneous and occur at the changes of generation. A cell dying for whatever reason may help cause birth, but a newborn cell cannot resurrect a cell that is dying, nor will a cell’s death prevent the death of another, say, by reducing the local population. Notes: Some configurations grow from relatively small starting configurations. Others move across the region. It is recommended that for text output you use a rectangular array of char with 80 columns and 22 rows to store the LIFE world’s successive genera- tions. Use an asterisk * to indicate a living cell, and use a blank to indicate an empty (or dead) cell. If you have a screen with more rows than that, by all means make use of the whole screen. Examples: *** becomes * * * then becomes *** again. and so on. Suggestions: Look for stable configurations. That is, look for communities that repeat patterns continually. The number of configurations in the repetition is called the period. There are configurations that are fixed, which continue without change. A possible project is to find such configurations. Hints: Define a void function named generation that takes the array we call world, an 80 column by 22 row array of char, which contains the initial configuration. The function scans the array and modifies the cells, marking the cells with births and deaths in accord with the rules listed earlier. This involves examining each cell in turn, either killing the cell, letting it live, or, if the cell is empty, deciding whether a cell should be born. There should be a function display that accepts the array world
  • 3. HW 7: More Arrays, Strings, Vectors, and Pointers Assigned: April 9, 2014 3 Due: May 4, 2014 and displays the array on the screen. Some sort of time delay is appropriate between calls to generation and display. To do this, your program should generate and display the next generation when you press Return. You are at liberty to automate this, but automation is not necessary for the program. Problem 3 Write a program that inputs two string variables, first and last, each of which the user should enter with his or her name. First, convert both strings to all lowercase. Your program should then create a new string that contains the full name in pig latin with the first letter capitalized for the first and last name. The rules to convert a word into pig latin are as follows: (a) If the first letter is a consonant move it to the end and add “ay” to the end. (b) If the first letter is a vowel, add “way” to the end. For example, if the user inputs “Erin” for the first name and “Jones” for the last name, then the program should create a new stnng with the text “Erinway Onesjay” and print it. Problem 4 You run four computer labs. Each lab comains computer stations that are numbered as shown in the table below: Lab Number Computer Station Numbers 1 1 – 5 2 1 – 6 1 1 – 4 1 1 – 3 Each user has a unique five-digit ID number. Whenever a user logs on, the user’s ID, lab number, and the computer station number are transmitted to your system. For example, if user 49193 logs onto station 2 in lab 3, then your system receives (49193, 2, 3) as input data. Similarly, when a user logs off a station, then your system receives the lab number and computer station number. Write a computer program that could be used to track, by lab, which user is logged onto which computer. For exarnple, if user 49193 is logged into station 2 in lab 3 and user 99577 is logged into station 1 of lab 4 then your system might display the following: Lab Number Computer Stations 1 1: empty 2: empty 3: empty 4: empty 5: empty 2 1: empty 2; empty 3: empty 4: empty 5: empty 6:empty 3 1: empty 2: 49193 3: empty 4: empty 4 1: 99577 2: empty 3: empty Create a menu that allows the administrator to simulate the transmission of information by manually typing in the login or logoff data. Whenever someone logs in or out, the
  • 4. HW 7: More Arrays, Strings, Vectors, and Pointers Assigned: April 9, 2014 4 Due: May 4, 2014 display should be updated. Also write a search option so that the administrator can type in a user ID and the system will output what lab and station number that user is logged into, or “None” if the user ID is not logged into any computer station. You should use a fixed array of length 4 for the labs. Each array entry points to a dynamic array that stores the user login information for each respective computer station. The structure is shown in the figure below. This structure is sometimes called a ragged array since the columns are of unequal length. Lab Array Dynamic Arrays for Computer Stations Problem 5 One problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array as you can with a vector. This project asks you to create functions that use dynamic arrays to emulate the behavior of a vector. First, write a program that creates a dynamic array of five strings. Store five names of your choice into the dynamic array. Next, complete the following two functions: string* addEntry(string *dynamicArray, int &size, string newEntry); This func- tion should create a new dynamic array one element larger than dynamtcArray, copy all elements from dynamicArray into the new array, add the new entry onto the end of the new array, increment size, delete dynamicArray, and return the new dynamic array. string* deleteEntry(string *dynamicArray, int &size, string entryToDelete); This function should search dynamicArray for entryToDelete. If not found, the request should be ignored and the unmodified dynamtcArray returned. If found, create a new dynamic array one element smaller than dynamicArray. Copy all elements except en- tryToDelete into the new array, delete dynamicArray, decrement size, and and return the new dynamic array. Test your functions by adding and deleting several names to the array while outputting the contents of the array. You will have to assign. the array returned by addEntry or deleteEntry back to the dynamic array variable in your main function.