Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

1

At first, do not use using namespace std do not use using namespace std.

2

You do not use any function from "math.h" header so you do not need to include it.

3

Next, using #include <windows.h> is also bad. You use it only for time measure. Standard C++ library has a dedicated header for this purpouse. It will make code more portable. Example:

#include <chrono>
// ... some code
auto startTime = std::chrono::high_resolution_clock::now();
// do calculations
auto endTime = std::chrono::high_resolution_clock::now();
// output
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
std::cout << "Total time: " << duration << " milliseconds.";

4

main function should always return int, and accepted arguments are either none or

(int, char* [])

5

Instead of #define macro, C++ uses const keyword:

const int runs = 1000;

1

At first, do not use using namespace std.

2

You do not use any function from "math.h" header so you do not need to include it.

3

Next, using #include <windows.h> is also bad. You use it only for time measure. Standard C++ library has a dedicated header for this purpouse. It will make code more portable. Example:

#include <chrono>
// ... some code
auto startTime = std::chrono::high_resolution_clock::now();
// do calculations
auto endTime = std::chrono::high_resolution_clock::now();
// output
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
std::cout << "Total time: " << duration << " milliseconds.";

4

main function should always return int, and accepted arguments are either none or

(int, char* [])

5

Instead of #define macro, C++ uses const keyword:

const int runs = 1000;

1

At first, do not use using namespace std.

2

You do not use any function from "math.h" header so you do not need to include it.

3

Next, using #include <windows.h> is also bad. You use it only for time measure. Standard C++ library has a dedicated header for this purpouse. It will make code more portable. Example:

#include <chrono>
// ... some code
auto startTime = std::chrono::high_resolution_clock::now();
// do calculations
auto endTime = std::chrono::high_resolution_clock::now();
// output
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
std::cout << "Total time: " << duration << " milliseconds.";

4

main function should always return int, and accepted arguments are either none or

(int, char* [])

5

Instead of #define macro, C++ uses const keyword:

const int runs = 1000;
Source Link
enedil
  • 662
  • 4
  • 14

1

At first, do not use using namespace std.

2

You do not use any function from "math.h" header so you do not need to include it.

3

Next, using #include <windows.h> is also bad. You use it only for time measure. Standard C++ library has a dedicated header for this purpouse. It will make code more portable. Example:

#include <chrono>
// ... some code
auto startTime = std::chrono::high_resolution_clock::now();
// do calculations
auto endTime = std::chrono::high_resolution_clock::now();
// output
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
std::cout << "Total time: " << duration << " milliseconds.";

4

main function should always return int, and accepted arguments are either none or

(int, char* [])

5

Instead of #define macro, C++ uses const keyword:

const int runs = 1000;
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /