tailieunhanh - Giáo trình tin học chương 4

Arrays • Array – Structures of related data items – Static entity (same size throughout program) – Consecutive group of memory locations – Same name and type (int, char, etc.) • To refer to an element – Specify array name and position number (index) – Format: arrayname[ position number ] – First element at position 0 | 1 Chapter 4 - Arrays Outline Introduction Arrays Declaring Arrays Examples Using Arrays Passing Arrays to Functions Sorting Arrays Searching Arrays Linear Search and Binary Search Multiple-Subscripted Arrays 2003 Prentice Hall Inc. All rights reserved. 2 Arrays Array - Structures of related data items - Static entity same size throughout program - Consecutive group of memory locations - Same name and type int char etc. To refer to an element - Specify array name and position number index - Format arrayname position number - First element at position 0 N-element array c c 0 c 1 . c n - 1 - Nth element as position N-1 2003 Prentice Hall Inc. All rights reserved. 3 Arrays Array elements like other variables - Assignment printing for an integer array c c 0 3 cout c 0 Can perform operations inside subscript c 5 - 2 same as c 3 2003 Prentice Hall Inc. All rights .

TỪ KHÓA LIÊN QUAN