mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-21 21:58:50 -05:00
Tests: Update CMake tutorial
Latest material from data.kitware.com -> Collections -> Courses -> CMake.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
// A simple program that computes the square root of a number
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "TutorialConfig.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef USE_MYMATH
|
||||
# include "MathFunctions.h"
|
||||
@@ -11,23 +12,21 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
|
||||
Tutorial_VERSION_MINOR);
|
||||
fprintf(stdout, "Usage: %s number\n", argv[0]);
|
||||
std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
|
||||
<< Tutorial_VERSION_MAJOR << std::endl;
|
||||
std::cout << "Usage: " << argv[0] << " number" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
double inputValue = atof(argv[1]);
|
||||
double outputValue = 0;
|
||||
double inputValue = std::stod(argv[1]);
|
||||
|
||||
if (inputValue >= 0) {
|
||||
#ifdef USE_MYMATH
|
||||
outputValue = mysqrt(inputValue);
|
||||
double outputValue = mysqrt(inputValue);
|
||||
#else
|
||||
outputValue = sqrt(inputValue);
|
||||
double outputValue = sqrt(inputValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
|
||||
std::cout << "The square root of " << inputValue << " is " << outputValue
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user