29 lines
683 B
C++
29 lines
683 B
C++
#include <iostream>
|
|
#include <cstdlib>
|
|
#include <cmath>
|
|
#include "TutorialConfig.h"
|
|
#ifdef USE_MYMATH
|
|
#include "MathFunctions.h"
|
|
#endif
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
// report version
|
|
if (argc < 2)
|
|
{
|
|
std::cout << argv[0] << " version " << Tutorial_VERSION_MAJOR
|
|
<< Tutorial_VERSION_MINOR << std::endl;
|
|
std::cout << "Usage: " << argv[0] << " number" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
const double inputValue = std::stod(argv[1]);
|
|
|
|
#ifdef USE_MYMATH
|
|
const double outputValue = mysqrt(inputValue);
|
|
#else
|
|
const double outputValue = sqrt(inputValue);
|
|
#endif
|
|
|
|
printf("%.0f is %.0f\n", inputValue, outputValue);
|
|
} |