This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:comporg:projects:pnc0 [2018/01/21 01:05] – [Program Format] ahought2 | notes:comporg:projects:pnc0 [2018/01/22 13:51] (current) – [Program Output Format] bstrong2 | ||
---|---|---|---|
Line 96: | Line 96: | ||
</ | </ | ||
- | =====Programs - Pick at least 5===== | + | =====Program Specifications===== |
- | **primereg** - baseline program (Brute force, no break)\\ \\ | + | **You must write AT LEAST 5 of the choices below.**\\ |
- | **primeregs** - baseline, plus square root trick (Use < | + | ** primereg.c / primeregb.c / primeregs.c / primeregbs.c are all REQUIRED** |
- | **primeregb** - baseline, plus break on composite\\ \\ | + | |
- | **primeregbs** - baseline, plus square root trick, plus break on composite\\ \\ | + | **Brute Force** - This is the no optimization method. |
+ | |||
+ | **Break on composite** - Once you can determine a number is NOT prime you can break from the the rest of the checks. | ||
+ | |||
+ | **Square root trick** - You can use the < | ||
+ | < | ||
+ | #include < | ||
+ | </ | ||
+ | |||
+ | **sqrt()-less square root approximation (a)-** This is optional, you would do this instead of the sqrt() function. (If you've taken discrete then you know how to do it, if you haven' | ||
+ | ---- | ||
+ | **primereg.c** - baseline program (Brute force, no break)\\ \\ | ||
+ | **primeregs.c** - baseline, plus square root trick (Use < | ||
+ | **primeregb.c** - baseline, plus break on composite\\ \\ | ||
+ | **primeregbs.c** - baseline, plus square root trick, plus break on composite\\ \\ | ||
**__Choice of A, R, or L__** \\ | **__Choice of A, R, or L__** \\ | ||
- | **primeregAbs** - baseline, array, square root trick, break on composite \\ \\ | + | **primeregAbs.c** - baseline, array, square root trick, break on composite \\ \\ |
**Note**: (Store prime divisors into array and check against the array) \\ | **Note**: (Store prime divisors into array and check against the array) \\ | ||
Array size(amount of elements) == argument 1(number of primes) \\ \\ | Array size(amount of elements) == argument 1(number of primes) \\ \\ | ||
- | **primeregRbs** - Recursive brain melter ? \\ | + | **primeregRbs.c** - Recursive brain melter ? \\ |
- | **primeregLbs** - Linked List | + | **primeregLbs.c** - Linked List - similar to primeregAbs - save primes in a linked list rather than an array. |
- | =====Program Format===== | + | =====Program |
<cli> | <cli> | ||
lab46: | lab46: | ||
Line 121: | Line 135: | ||
-**Put all c files in gcc directory from pnc0 grabit** \\ | -**Put all c files in gcc directory from pnc0 grabit** \\ | ||
- | -Numbers go to stderr, time goes to stdout \\ | + | -Numbers go to stderr, |
+ | |||
+ | =====Testing===== | ||
+ | To test your output of STDERR vs STDOUT:\\ | ||
+ | Redirect your STDERR to **/ | ||
+ | < | ||
+ | lab46: | ||
+ | 0.0001 | ||
+ | lab46: | ||
+ | </ | ||
+ | Redirect your STDOUT to **/ | ||
+ | < | ||
+ | lab46: | ||
+ | 2 3 5 7 11 13 17 19 | ||
+ | lab46: | ||
+ | </ | ||
To test your output time tests you can do the following: | To test your output time tests you can do the following: | ||
<cli> | <cli> | ||
lab46: | lab46: | ||
+ | </ | ||
+ | |||
+ | Also do not forget about error checking!\\ | ||
+ | EXAMPLE:\\ | ||
+ | <cli> | ||
+ | lab46: | ||
+ | Incorrect Number of Arguments! | ||
+ | ./primereg QUANTITY | ||
+ | lab46: | ||
</ | </ | ||