Worth a mention ...
The BlitzMax IDE (v1.12) can now handle simple C/C++ code.
Here's something for you to try:
* Save the source code below as:
Sieve.cpp
* Now open 'Sieve.cpp' in the BLitzMax IDE
* Hit F5 to compile.
* Bingo. Executable created.
Note: Ensure the files extension is *.c or *.cpp to prevent the MaxIDE from converting commands to capitalised versions.
(Credits go to FlameDuck for the source code)
The BlitzMax IDE (v1.12) can now handle simple C/C++ code.
Here's something for you to try:
* Save the source code below as:
Sieve.cpp
* Now open 'Sieve.cpp' in the BLitzMax IDE
* Hit F5 to compile.
* Bingo. Executable created.
Note: Ensure the files extension is *.c or *.cpp to prevent the MaxIDE from converting commands to capitalised versions.
(Credits go to FlameDuck for the source code)
#include <iostream> #include <ctime> #include <conio.h> int main(int argc, char* argv[]) { int const ITERATIONS = 50000; std::cout << "SIEVE OF ERATOSTHENES - " << ITERATIONS << " iterations\n"; int cps = CLOCKS_PER_SEC / 1000; long t = std::clock(); int Count; for(int Iter = 1; Iter <= ITERATIONS; Iter++) { int flags[8191]; int i = 0; int k = 0; int prime = 0; Count = 0; for (i = 0; i <= 8190; i++) { flags[i] = 1; } for (i = 0; i <= 8190; i++) { if (flags[i] == 1) { prime = i + i; prime = prime +3; k = i + prime; while (k <= 8190) { flags[k] = 0; k = k + prime; } Count = Count + 1; } } } t = std::clock() - t; t = t / cps; // because there might be more than 1000 CLOCKS_PER_SECOND std::cout << ITERATIONS << " iterations took " << t << " millisecs.\n"; std::cout << "Primes found: " << Count << "\n"; std::cout << "Any key to end ..."; getch(); }Now you can dabble in a bit of C without having to install other doings.