-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays1.cpp
More file actions
56 lines (45 loc) · 1.15 KB
/
arrays1.cpp
File metadata and controls
56 lines (45 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @file arrays1.cpp
* @author The CS2 TA Team <cs2tas@caltech.edu>
* @date 2014-2015
* @copyright This code is in the public domain.
*
* @brief An array example.
*/
#include <iostream>
#include <cstdlib>
#include <ctime>
#define TEST_SIZE 60
using namespace std;
//
// TODO: put user functions here
//
/**
* @brief Sets up and runs an array example.
*/
int main(int argc, char ** argv)
{
/*-------- CHANGE NOTHING BELOW THIS LINE FOR PART 1 --------*/
int test_values[TEST_SIZE];
int real_size;
// seed the PRNG
srand(time(nullptr));
// initialize the test array to garbage
for (int i = 0; i < TEST_SIZE; i++)
{
test_values[i] = rand();
}
// determine a real size
real_size = TEST_SIZE - (rand() % 20);
// initialize the meaningful part of the test array to random numbers
// all of which are less than one million
for (int i = 0; i < real_size; i++)
{
test_values[i] = rand() % 1000000;
}
/*-------- CHANGE NOTHING ABOVE THIS LINE FOR PART 1 --------*/
//
// TODO: do your stuff here with the array `test_values`
// of dynamic size `real_size`
//
}