This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2022:projects:cnv0 [2022/09/16 02:56] – [SPECIFICATIONS] abarbcal | notes:discrete:fall2022:projects:cnv0 [2022/09/22 01:56] (current) – [PROGRAM] dmuck | ||
---|---|---|---|
Line 26: | Line 26: | ||
The n-ary value of something is determined by the number of " | The n-ary value of something is determined by the number of " | ||
=====ALGORITHM: | =====ALGORITHM: | ||
+ | Somewhere in the algorithm you may need to make use of the modulo (%) operator. The modulo operator gives you the remainder after a division. For example 5 % 2 would give you 1, since there is a remainder of 1 after dividing 5 by 2. This operator can be used to check if the result of two numbers being divided is a whole number (divider % divisor == 0). | ||
=====SPECIFICATIONS===== | =====SPECIFICATIONS===== | ||
- | Once you've grabbed the cnv0 project directory, with the **grabit** command, you will have a skeleton source code file. | + | It is our task to build a program that will calculate and display |
- | This source code contains structs, functions, | + | This program will be timed and we will compare this program's computational time to future project' |
+ | The computational time of the program should start prior to your algorithm | ||
+ | |||
+ | |||
- | The program cnv0 will take 4 arguments, two are mandatory and two are optional. | ||
*Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, | *Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, | ||
Line 38: | Line 41: | ||
*For anybody interested in editing the wiki page, here is the dokuwiki user guide: [[https:// | *For anybody interested in editing the wiki page, here is the dokuwiki user guide: [[https:// | ||
=====PROGRAM===== | =====PROGRAM===== | ||
- | cnv0 will take a minimum of 2 and a maximum of 4 arguments. The first will be a quantity of how many numbers to output. The second will be the n-ary value, and the third will be the lower-bound of where to begin checking values, and the fourth will be the upper-bound of where to stop checking values. | ||
- | =====OUTPUT SPECIFICATIONS===== | ||
+ | Once you've grabbed the cnv0 project directory, with the **grabit** command, you will have a skeleton source code file. This source code contains structs, functions, and a fprintf statement that will calculate how long it takes for your program to finish processing. This is only for timekeeping and referencing, | ||
+ | |||
+ | **Note:** If you are coding this project in c++ you should modify the Makefile that way make can still build the project. To do this go to the top of the make file and change CC=gcc to CC=g++, as well as removing the flag —-std=gnu18 two lines above. | ||
+ | |||
+ | The cnv0 program will accept 4 arguments, two are mandatory and two are optional. | ||
+ | |||
+ | < | ||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | <cli> | ||
+ | | ||
+ | argv[0] argv[1] argv[2] | ||
+ | </ | ||
+ | |||
+ | The first two arguments are mandatory, qty and nary. | ||
+ | |||
+ | The qty argument stands for quantity, this argument indicates how many **n-ary** will be displayed to output, from all the n-ary numbers available. | ||
+ | example: If the program is looking for " | ||
+ | Therefore: 4 is second-ary, 10 is second-ary, and 14 is second-ary. (only display 3) | ||
+ | |||
+ | The nary argument stands for the n-ary degree, this argument indicates how many factor pairs a number is expected to have. 1 for n-ary is a prime number, with one factor pair, 10 for n-ary is a " | ||
+ | |||
+ | The two last arguments are optional, start and end. | ||
+ | |||
+ | The start argument is the lower bound of where the program will begin to check for n-ary numbers. | ||
+ | |||
+ | The end argument is the upper bound of where the program will stop checking for n-ary values. | ||
+ | |||
+ | Hence, if you have the following case: | ||
+ | < | ||
+ | lab46: | ||
+ | 7 11 13 17 19 | ||
+ | </ | ||
+ | |||
+ | What these arguments are indicating is display 5 numbers, that are prime, start from seven, and stop at 20. | ||
+ | |||
+ | The program is to display timing information as well, with the core computation part of this project between the starting and stopping of the timer. This functionality is already included in the cnv0.c you grabbed. | ||
+ | |||
+ | =====OUTPUT SPECIFICATIONS===== | ||
+ | Output should be a space separated list of matching n-ary values with a newline at the end. Beneath that should be the amount of time it took for your script to complete. This doesn' | ||
=====VERIFICATION===== | =====VERIFICATION===== | ||
+ | There is no verify file so in order to verify that your script is working correctly, you can do this manually. To do so, you can enter values into your script, figure out what the output should be, and see if your script outputs that. If it doesn' | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | 1 2 3 5 7 11 13 | ||
+ | x.xxxx (Time) | ||
+ | </ | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | 4 6 8 9 10 14 15 | ||
+ | x.xxxx (Time) | ||
+ | </ | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | 12 16 | ||
+ | x.xxxx (Time) | ||
+ | </ | ||
+ | |||
+ | |||