This way, you don't have to cut and paste main() from here
to there, there's no chance you'll accidentally submit
a main() with your code, and it's easy to test your
program using someone else's main() simply by
compiling like so:
g++ -Wall -g -o functions functions.cpp othermain.cpp.
////////////////////////////////////////////////////////////////// // // IsPerfect returns true if the given integer N is // a perfect number, and false otherwise. // // N is perfect if it is positive and the sum of its // factors (not including N itself) is equal to N. // For example, 28 is perfect, since 1 + 2 + 4 + 7 + 14 = 28. // 12 is not perfect, since 1 + 2 + 3 + 4 + 6 != 12. // ////////////////////////////////////////////////////////////////// bool IsPerfect( int N ); ////////////////////////////////////////////////////////////////// // // ReduceFraction // // Preconditions: numerator and denominator contain the // numerator and denominator of a fraction to be reduced. // // Postconditions: // 1. The parameters contain the numerator and denominator // of the reduced fraction. // // 2. If the fraction is positive, both numerator and // denominator of the reduced fraction should be // positive. // // 3. If the fraction is negative, the numerator of the // reduced fraction should be negative, and the // denominator positive. // // 4. If denominator is initially zero, neither numerator // nor denominator should be changed. // // // Examples. Before After // n=6, d=9 n=2, d=3 // n=6, d=-9 n=-2, d=3 // n=-7, d=0 n=-7, d=0 // ////////////////////////////////////////////////////////////////// void ReduceFraction( int& numerator, int& denominator ); ////////////////////////////////////////////////////////////////// // // RemovePunctuation replaces the contents of theString with // the same contents, but with all punctuation removed. // Punctuation characters are defined to be those characters // for which the standard library function "ispunct" returns // true. // // Example. Before After // // "Don't shoot!" "Dont shoot" // ////////////////////////////////////////////////////////////////// void RemovePunctuation( string& theString );