CPPForSchool.com: Array - Single Dimension Set 1 Assignment 3
3.
Write a C++ program to reverse the element of an integer 1-D array.
This assignment was not too difficult, but my approach is quite different than the assignment solution. My approach was to utilize another array to store the temporary values, followed by replacing back the values in the current reverse order. When compared to the sample solution, I'm not sure which is more effective. Needless to say, I was able to successfully accomplish the goal of the assignment. Below is my "over engineered" code, followed by the sample solution. It is important to note that I have purposely "over engineered" my code in order to get use to using functions. Also, I wanted to step up the overall aesthetics and feel of the program so it feels a bit more user friendly. Granted, there is no GUI yet, but I figured that this would be a great time to exercise best practices. I believe that even with these small programs, it is important to install good standard practices as early as possible.
This assignment was not too difficult, but my approach is quite different than the assignment solution. My approach was to utilize another array to store the temporary values, followed by replacing back the values in the current reverse order. When compared to the sample solution, I'm not sure which is more effective. Needless to say, I was able to successfully accomplish the goal of the assignment. Below is my "over engineered" code, followed by the sample solution. It is important to note that I have purposely "over engineered" my code in order to get use to using functions. Also, I wanted to step up the overall aesthetics and feel of the program so it feels a bit more user friendly. Granted, there is no GUI yet, but I figured that this would be a great time to exercise best practices. I believe that even with these small programs, it is important to install good standard practices as early as possible.
Admittedly, I am really starting to enjoy this granular approach to coding. It helps keep things in line much easier. To be more specific, I am really enjoying the notion of coding without any worry of "borking" prior code.
Comments
Post a Comment