Introduction to C++ Programming Language Assistant Professor Jeon, Seokhee Assistant Professor...
-
Upload
barbara-jefferson -
Category
Documents
-
view
216 -
download
2
Transcript of Introduction to C++ Programming Language Assistant Professor Jeon, Seokhee Assistant Professor...
Introduction to C++ Introduction to C++ Programming LanguageProgramming Language
Jeon, Seokhee
Assistant ProfessorAssistant ProfessorDepartment of Computer Engineering,Department of Computer Engineering,
Kyung Hee University, KoreaKyung Hee University, Korea
CHAPTER 8CHAPTER 8ArrayArray
Derived TypesDerived Types
Ten VariablesTen Variables
Processing Ten VariablesProcessing Ten Variables
An Array of ScoresAn Array of Scores
The Scores ArrayThe Scores Array
Loop for Ten ScoresLoop for Ten Scores
Declaring and defining arraysDeclaring and defining arrays
Initializing arraysInitializing arrays
Exchanging scores-the wrong wayExchanging scores-the wrong way
Exchanging scores with temporary Exchanging scores with temporary variablevariable
Squares ArraySquares Array
Print Input ReversedPrint Input Reversed
Passing individual elements to functionPassing individual elements to function
Passing arrays—averagePassing arrays—average
Prevent x from being changed.
Use x just for refering
Prevent x from being changed.
Use x just for refering
Changing values in arraysChanging values in arrays
Random Number Random Number PermutationPermutation
SORTING IN ARRAYSORTING IN ARRAY
Selection sort conceptSelection sort concept
Selection sort exampleSelection sort example
Selection Sort CodeSelection Sort Code
Bubble sort conceptBubble sort concept
Bubble sort exampleBubble sort example
Bubble Sort CodeBubble Sort Code
Insertion sort conceptInsertion sort concept
Insertion sort exampleInsertion sort example
Insertion Sort CodeInsertion Sort Code
SEARCHING IN ARRAYSEARCHING IN ARRAY
Search conceptSearch concept
Sequential SearchSequential Search
Unsuccessful searchUnsuccessful search
Sequential Search CodeSequential Search Code
Binary search exampleBinary search example
Note that the list is Note that the list is already sorted already sorted
Unsuccessful binary search exampleUnsuccessful binary search example
Binary Search CodeBinary Search Code
Useful materials on sorting and Useful materials on sorting and searching algorithmssearching algorithms
• http://www.sorting-algorithms.com/
• http://www.cosc.canterbury.ac.nz/mukundan/dsal/appldsal.html
• http://www.cs.auckland.ac.nz/~jmor159/PLDS210/alg_anim.html
Two-dimensional arrayTwo-dimensional array
Array of arraysArray of arrays
Memory layoutMemory layout
Passing a row Passing a row
Calculate average of integers in arrayCalculate average of integers in array
Fill MatrixFill Matrix
A three-dimensional array (3 x 5 x 4)A three-dimensional array (3 x 5 x 4)
C++ view of three-dimensional arrayC++ view of three-dimensional array
Initializing a three-dimensional arrayInitializing a three-dimensional array