Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2sem1.2 #34

Merged
merged 15 commits into from Mar 16, 2021
2 changes: 2 additions & 0 deletions Homework2/BubbleSort/BubbleSort/BubbleSort.vcxproj
Expand Up @@ -141,6 +141,8 @@
<ItemGroup>
<ClCompile Include="Source.c">
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</SDLCheck>
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</SDLCheck>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже какие-то лишние коммиты в пуллреквесте :) Замерджили бы все C++ные изменения в мастер, да и всё

<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</SDLCheck>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
7 changes: 4 additions & 3 deletions Homework2/BubbleSort/BubbleSort/Source.c
Expand Up @@ -67,11 +67,12 @@ int fourthTest() {
int main() {
if (firstTest() == 0 || secondTest() == 0 || thirdTest() == 0 || fourthTest() == 0) {
printf("Test failed\n");
return 0;
return 1;
}
return 0;

int size = 100000;
int a[100000];
int size = 1000;
int a[1000];
for (int i = 0; i < size; ++i) {
a[i] = size - i - 1;
}
Expand Down
Expand Up @@ -141,6 +141,8 @@
<ItemGroup>
<ClCompile Include="Source.c">
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</SDLCheck>
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</SDLCheck>
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</SDLCheck>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
58 changes: 18 additions & 40 deletions Homework2/CountingSort/CalculationSort/Source.c
@@ -1,6 +1,6 @@
#include <stdio.h>
#include <malloc.h>
#include <conio.h>
#include <stdbool.h>
#include <time.h>

void calculationSort(int size, int a[])
Expand All @@ -16,11 +16,7 @@ void calculationSort(int size, int a[])
}
}

int* helpingArray = (int*)malloc((max + 1) * sizeof(int));

for (int i = 0; i < max - min + 1; ++i) {
helpingArray[i] = 0;
}
int* helpingArray = calloc((max + 1), sizeof(int));

for (int i = 0; i < size; ++i) {
helpingArray[a[i] - min]++;
Expand All @@ -36,29 +32,23 @@ void calculationSort(int size, int a[])
free(helpingArray);
}

int sortCheck(int a[], int size) {
for (int i = 0; i < size; ++i) {
bool sortCheck(int a[], int size) {
for (int i = 0; i < size - 1; ++i) {
if (a[i] > a[i + 1]) {
return 0;
return false;
}
}
return 1;
return true;
}

int firstTest() {
int a[10000];
for (int i = 0; i < 10000; ++i) {
a[i] = 10000 - i - 1;
int a[1000];
for (int i = 0; i < 1000; ++i) {
a[i] = 1000 - i - 1;
}

calculationSort(10000, a);
int check = sortCheck(a, 10000);
if (check == 1) {
return 1;
}
else {
return 0;
}
calculationSort(1000, a);
return sortCheck(a, 1000);
}

int secondTest() {
Expand All @@ -68,45 +58,33 @@ int secondTest() {
}

calculationSort(10, a);
int check = sortCheck(a, 10);

if (check == 1) {
return 1;
}
else {
return 0;
}
return sortCheck(a, 10);
}

int thirdTest() {
int a[] = { 7, 8, 3, 4, 1, 2, 6, 5, 2 };

calculationSort(9, a);
int check = sortCheck(a, 9);
if (check == 1) {
return 1;
}
else {
return 0;
}
return sortCheck(a, 9);
}

int fourthTest() {
int a[] = { 1 };
calculationSort(1, a);
for (int i = 0; i < 1; ++i) {
if (a[i] != 1) {
return 0;
return false;
}
}
return 1;
return true;
}

int main() {
if (firstTest() == 0) {
if (!firstTest() || !secondTest() || !thirdTest() || !fourthTest()) {
printf("Test failed\n");
return 0;
return 1;
}
return 0;

int size = 0;
printf("Input size of array: ");
Expand Down
5 changes: 4 additions & 1 deletion Homework2/Fibonacci/Fibonacci/Fibonacci.vcxproj
Expand Up @@ -139,7 +139,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="RecursiveFibonacci.c" />
<ClCompile Include="RecursiveFibonacci.c">
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</SDLCheck>
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</SDLCheck>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
6 changes: 3 additions & 3 deletions Homework2/Fibonacci/Fibonacci/RecursiveFibonacci.c
Expand Up @@ -23,11 +23,11 @@ int test() {

int main() {

int testing = test();
if (testing == 0) {
if (!test()) {
printf("Test failed\n");
return 0;
return 1;
}
return 0;

int n = 0;
printf("Enter the number: ");
Expand Down
2 changes: 2 additions & 0 deletions Homework2/Pow/Pow/Pow.vcxproj
Expand Up @@ -141,6 +141,8 @@
<ItemGroup>
<ClCompile Include="Source.c">
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</SDLCheck>
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</SDLCheck>
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</SDLCheck>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
19 changes: 10 additions & 9 deletions Homework2/Pow/Pow/Source.c
@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdbool.h>

int binaryPower(int number, int power) {
if (power == 0) {
Expand Down Expand Up @@ -37,18 +38,18 @@ int testSlowPower() {
return 0;
}

int main() {
int firstTest = testBinaryPower();
if (firstTest == 0) {
printf("Test failed\n");
return 0;
bool test() {
if (!testBinaryPower() || !testSlowPower()) {
return false;
}
return true;
}

int secondTest = testSlowPower();
if (secondTest == 0) {
printf("Test failed\n");
return 0;
int main() {
if (!test()) {
return 1;
}
return 0;

int number = 0;
int power = 0;
Expand Down
8 changes: 8 additions & 0 deletions SecondSemester/Homework1/BWT/BWT.csproj
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions SecondSemester/Homework1/BWT/BWT.sln
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BWT", "BWT.csproj", "{1547F460-E1F0-4597-96B5-B1865C4A0AA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1547F460-E1F0-4597-96B5-B1865C4A0AA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1547F460-E1F0-4597-96B5-B1865C4A0AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1547F460-E1F0-4597-96B5-B1865C4A0AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1547F460-E1F0-4597-96B5-B1865C4A0AA6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {706C05FC-DD3C-432F-9E0B-DF9721F40210}
EndGlobalSection
EndGlobal