| 1 | // File: fig0638.cpp |
| 2 | // Computer Systems, Fourth Edition |
| 3 | // Figure 6.38 |
| 4 | |
| 5 | #include <iostream> |
| 6 | using namespace std; |
| 7 | |
| 8 | void getVect (int v[], int& n) { |
| 9 | int j; |
| 10 | cin >> n; |
| 11 | for (j = 0; j < n; j++) { |
| 12 | cin >> v[j]; |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | void putVect (int v[], int n) { |
| 17 | int j; |
| 18 | for (j = 0; j < n; j++) { |
| 19 | cout << v[j] << ' '; |
| 20 | } |
| 21 | cout << endl; |
| 22 | } |
| 23 | |
| 24 | int main () { |
| 25 | int vector[8]; |
| 26 | int numItms; |
| 27 | getVect (vector, numItms); |
| 28 | putVect (vector, numItms); |
| 29 | return 0; |
| 30 | } |