## Homework

## The Usual Suspects

This class is pretty much just about typical operations using arrays. For the moment we won't worry about putting these operations in functions!

## Statistical Operations

You may want the files data.txt and numbers.txt.

## Other Array Problems

You may want the files data.txt and numbers.txt.

- Start with the program:

```
#include <iostream>
using namespace std;
int main() {
// read size n, allocate array of n doubles, read values into array
int n;
cin >> n;
double * A = new double[n];
for(int i = 0; i < n; i++)
cin >> A[i];
// Now what?
return 0;
}
```

... and add code after the "Now what?" comment to solve one of the problems below for the array A of n elements created in the first part of the code.

Print out the index of the minimum element in the array. So, for example:

`~/$ ./ex1a 4 34 12 8 29 minimum element is A[2] = 8.`

**Solution:**TE7a.cppPrint elements of the array, separated by commas. So, for example:

`~/$ ./ex1b 4 34 12 8 29 A = [34, 12, 8, 29]`

**Solution:**TE7b.cppCreate and print array of the "partial differences" of consecutive elements in the array. Here's an example of a sequence of four numbers along with the sequence of partial differences (note that there are only three elements in that sequence).

`3 7 8 5 \_/ \_/ \_/ 2 1 -3`

A run of your program should look like this:

`~/$ ./ex1c 4 14 16 8 29 2 -8 21`

**Solution:**TE7c.cppSplit positive and negative. I actually want you to create two new arrays, one containing the positive elements of A, and one containing the negative elements of A. Zeros in A should be ignored. These arrays should be exactly the right size (no extra cells), and you program should print each array out. A run of your program should look like this:

`~/$ ./ex1d 10 0 1 2 -3 4 -5 -6 7 8 9 negative: -3 -5 -6 positive: 1 2 4 7 8 9`

**Solution:**TE7d.cpp

- histograms (arrays of counters)
- masks (i.e. an array of bools), for example to implement a simple hangman game.