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/18 14:37] – [Program Format] abratkov | notes:comporg:projects:pnc0 [2018/01/22 13:51] (current) – [Program Output Format] bstrong2 | ||
---|---|---|---|
Line 96: | Line 96: | ||
</ | </ | ||
- | =====Programs===== | + | =====Program Specifications===== |
- | **primereg** - baseline program\\ \\ | + | **You must write AT LEAST 5 of the choices below.**\\ |
- | **primeregs** - baseline, plus square root trick\\ \\ | + | ** 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 | ||
+ | **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 Output Format===== | ||
+ | < | ||
+ | lab46: | ||
+ | 2 3 5 7 11 13 17 19 | ||
+ | 0.0001 | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | The primereg files will take One argument. | ||
+ | Clarification: | ||
+ | |||
+ | -**Put all c files in gcc directory from pnc0 grabit** \\ | ||
+ | -Numbers go to stderr, **time goes to stdout** \\ | ||
+ | |||
+ | =====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: | ||
+ | < | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | Also do not forget about error checking!\\ | ||
+ | EXAMPLE: | ||
+ | < | ||
+ | lab46: | ||
+ | Incorrect Number of Arguments! | ||
+ | ./primereg QUANTITY | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | =====Submission===== | ||
+ | To submit, run:\\ | ||
+ | < | ||
+ | lab46: | ||
+ | </ | ||
+ | if you run into trouble edit the makefile and on line 47 where it says "save: clean" remove the word " | ||
- | =====Program Format===== | + | Also you can try |
- | **./ | + | <cli> |
- | The argument notates how many primes (starting from 2) that you want to print. | + | lab46:~/src/ |
- | Example: ./primereg 8 results in printing out: 2 3 5 7 11 13 17 19 \\ | + | </ |
- | \\ | + | |
- | **Put all c files in gcc directory from pnc0 grabit** | + |