Wednesday, July 9, 2014

Sorting out arrays and my life...

Dan the Man gave us the task of creating three programs: bubble sort, selection sort, and insertion sort. Dan helped us out withe the bubble sort and then made us a template for the other two programs. These are the two functions we wrote for the sorting within the program.


This program was a lot harder that the last one we did, not to mention the fact that we were making it way more complicated that it needed to be. It took several days to get the algorithm right for each sorting method. For me the hardest part was the "user_choice" function.

Tuesday, June 24, 2014

WE DID IT!!!

Today my partner, Jordan, and I wrote out first program for Lab #1.

The assignment given to us by Dan the Man (a.k.a. the fleet-footed horse) was to find the minimum, maximum, and mean value of a set of data. The set of data was a file that contained randomly generated numbers.

The first thing we had to do was open the file and tell the program to read it line by line. While it's reading each line, it is comparing each number to three predetermined variables : "number", "minimum", and "maximum" which were all set equal to zero. We used an if-loop as well as an else if-loop within a while loop. Basically, as the program is reading the file line by line, it stores each value into either the variable "minimum" or the variable "maximum" depending on whether or not it is greater or less than "number". We also made a variable "total" which serves as a counter for the total amount of numbers in the list. This value was used to find the mean/average value of all the numbers once they were added together.

The last thing we did was create a file with all the results. We used the "outputfile" command to create a vim file with each answer labeled.

Displaying photo.JPG