diff --git a/Sieve_of_Eratosthenes-example/build.bat b/Sieve_of_Eratosthenes-example/build.bat new file mode 100644 index 0000000..03d1d52 --- /dev/null +++ b/Sieve_of_Eratosthenes-example/build.bat @@ -0,0 +1,2 @@ +@echo off +call ../vcppbuild.bat main \ No newline at end of file diff --git a/Sieve_of_Eratosthenes-example/build.sh b/Sieve_of_Eratosthenes-example/build.sh new file mode 100644 index 0000000..5b277ac --- /dev/null +++ b/Sieve_of_Eratosthenes-example/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +g++ -o main main.cpp +./main \ No newline at end of file diff --git a/Sieve_of_Eratosthenes-example/main.cpp b/Sieve_of_Eratosthenes-example/main.cpp new file mode 100644 index 0000000..b3a63a2 --- /dev/null +++ b/Sieve_of_Eratosthenes-example/main.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +#define ARRAY_SIZE 32 + +int main() +{ + int arr[ARRAY_SIZE]; // 0 - 31 + for(int i = 0; i < ARRAY_SIZE - 1; i++) + { + arr[i] = 2 + i; + } + int index = 0; + while(index < ARRAY_SIZE - 1) + { + if (arr[index] == 0) + { + index += 1; + continue; + } + for (int i = index + arr[index]; i < ARRAY_SIZE - 1; i += arr[index]) + { + arr[i] = 0; + } + index += 1; + + } + for(int i = 0; i < ARRAY_SIZE - 1; i++) + { + if (arr[i] != 0) + cout << arr[i] << " "; + } +} \ No newline at end of file diff --git a/cp-Linux/build.sh b/cp-Linux/build.sh index 4cac8be..5b277ac 100644 --- a/cp-Linux/build.sh +++ b/cp-Linux/build.sh @@ -1,4 +1,4 @@ #!/bin/bash -gcc -o main main.cpp +g++ -o main main.cpp ./main \ No newline at end of file diff --git a/cp-homework/build.sh b/cp-homework/build.sh index 4cac8be..5b277ac 100644 --- a/cp-homework/build.sh +++ b/cp-homework/build.sh @@ -1,4 +1,4 @@ #!/bin/bash -gcc -o main main.cpp +g++ -o main main.cpp ./main \ No newline at end of file diff --git a/cp/build.sh b/cp/build.sh index 21798a7..38642e8 100644 --- a/cp/build.sh +++ b/cp/build.sh @@ -1,4 +1,4 @@ #!/bin/bash -gcc -o main main.cpp +g++ -o main main.cpp ./main test.txt test2.txt \ No newline at end of file diff --git a/ptypes-tcp/build.sh b/ptypes-tcp/build.sh index 15bfec9..1a8da61 100644 --- a/ptypes-tcp/build.sh +++ b/ptypes-tcp/build.sh @@ -1,4 +1,4 @@ #!/bin/bash -gcc -o client -lptypes client.cpp -gcc -o server -lptypes server.cpp +g++ -o client -lptypes client.cpp +g++ -o server -lptypes server.cpp diff --git a/vcppbuild.bat b/vcppbuild.bat index a948ee6..f368e90 100644 --- a/vcppbuild.bat +++ b/vcppbuild.bat @@ -13,5 +13,5 @@ if exist "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" ( goto compile ) :compile -cl.exe /Zi /nologo /W3 /WX- /O2 /Ob1 /Oy- /D "_CONSOLE" /D "NDEBUG" /D "WIN32" /D "_VC80_UPGRADE=0x0600" /D "_MBCS" /GF /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /I"..\ext\include" %1.cpp %2 +cl.exe /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /I"..\ext\include" %1.cpp %2 del %1.obj \ No newline at end of file