Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vs/
31 changes: 31 additions & 0 deletions EXTRATASK1/EXTRATASK1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36414.22 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EXTRATASK1", "EXTRATASK1.vcxproj", "{A8F2F49F-B89B-4E22-A687-6D934A455851}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Debug|x64.ActiveCfg = Debug|x64
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Debug|x64.Build.0 = Debug|x64
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Debug|x86.ActiveCfg = Debug|Win32
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Debug|x86.Build.0 = Debug|Win32
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Release|x64.ActiveCfg = Release|x64
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Release|x64.Build.0 = Release|x64
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Release|x86.ActiveCfg = Release|Win32
{A8F2F49F-B89B-4E22-A687-6D934A455851}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A7C7F94-90CD-4036-8D10-B2F00CCA6B92}
EndGlobalSection
EndGlobal
135 changes: 135 additions & 0 deletions EXTRATASK1/EXTRATASK1.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{a8f2f49f-b89b-4e22-a687-6d934a455851}</ProjectGuid>
<RootNamespace>EXTRATASK1</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="extra-task-1.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="extra-task-1.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
30 changes: 30 additions & 0 deletions EXTRATASK1/EXTRATASK1.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Исходные файлы">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Файлы заголовков">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Файлы ресурсов">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="extra-task-1.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="extra-task-1.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions EXTRATASK1/EXTRATASK1.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
11 changes: 11 additions & 0 deletions EXTRATASK1/EXTRATASK1/x64/Debug/EXTRATASK1.exe.recipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\x64\Debug\EXTRATASK1.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>
Binary file added EXTRATASK1/EXTRATASK1/x64/Debug/EXTRATASK1.ilk
Binary file not shown.
2 changes: 2 additions & 0 deletions EXTRATASK1/EXTRATASK1/x64/Debug/EXTRATASK1.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
 extra-task-1.cpp
EXTRATASK1.vcxproj -> C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\x64\Debug\EXTRATASK1.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions EXTRATASK1/EXTRATASK1/x64/Debug/EXTRATASK1.tlog/Cl.items.tlog
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\extra-task-1.cpp;C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\EXTRATASK1\x64\Debug\extra-task-1.obj
C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\main.cpp;C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\EXTRATASK1\x64\Debug\main.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.44.35207:TargetPlatformVersion=10.0.26100.0:
Debug|x64|C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\|
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^C:\USERS\VITALY\DESKTOP\CS211-EXTRA-TASK-1\EXTRATASK1\EXTRATASK1\X64\DEBUG\EXTRA-TASK-1.OBJ|C:\USERS\VITALY\DESKTOP\CS211-EXTRA-TASK-1\EXTRATASK1\EXTRATASK1\X64\DEBUG\MAIN.OBJ
C:\Users\Vitaly\Desktop\cs211-extra-task-1\EXTRATASK1\EXTRATASK1\x64\Debug\EXTRATASK1.ilk
Binary file not shown.
Binary file added EXTRATASK1/EXTRATASK1/x64/Debug/extra-task-1.obj
Binary file not shown.
Binary file added EXTRATASK1/EXTRATASK1/x64/Debug/main.obj
Binary file not shown.
Binary file added EXTRATASK1/EXTRATASK1/x64/Debug/vc143.idb
Binary file not shown.
Binary file added EXTRATASK1/EXTRATASK1/x64/Debug/vc143.pdb
Binary file not shown.
79 changes: 79 additions & 0 deletions EXTRATASK1/extra-task-1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <iostream>
#include <cassert>
#include <cmath>
#include "extra-task-1.h"

double seconds_difference(double time_1, double time_2)
{
// your implementation goes here...

assert(time_1 >= 0.0);
assert(time_2 >= 0.0);
return time_2 - time_1;
}

double hours_difference(double time_1, double time_2)
{
assert(time_1 >= 0.0);
assert(time_2 >= 0.0);

return (time_2 - time_1) / 3600.0;
}


double to_float_hours(int hours, int minutes, int seconds)
{
assert(minutes >= 0 && minutes < 60);
assert(seconds >= 0 && seconds < 60);
assert(hours >= 0);

auto total_hours = hours + (minutes / 60.0) + (seconds / 3600.0);
return total_hours;
}

double to_24_hour_clock(double hours)
{
assert(hours >= 0);
auto res = std::fmod(hours, 24);

if (std::fabs(res - 24.0) < EPS)
return 0.0;
return res;
}

int get_hours(int seconds)
{
assert(seconds >= 0);
return (seconds / 3600) % 24;
}

int get_minutes(int seconds)
{
assert(seconds >= 0);
return (seconds % 3600) / 60;
}

int get_seconds(int seconds)
{
assert(seconds >= 0);
return seconds % 60;
}

double time_to_utc(int utc_offset, double time)
{
assert(time >= 0.0 && time < 24.0);
assert(utc_offset >= -12 && utc_offset <= 14);

auto time2 = time - utc_offset;

return time2 >= 24.0 ? time2 - 24.0 : time2 < 0.0 ? time2 + 24.0 : time2;
}

double time_from_utc(int utc_offset, double time)
{
assert(time >= 0.0 && time < 24.0);
assert(utc_offset >= -12 && utc_offset <= 14);

double time2 = time + utc_offset;
return time2 >= 24.0 ? time2 - 24.0 : time2 < 0.0 ? time2 + 24.0 : time2;
}
12 changes: 12 additions & 0 deletions EXTRATASK1/extra-task-1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

const double EPS = 1e-6;
double seconds_difference(double, double);
double hours_difference(double, double);
double to_float_hours(int, int, int);
double to_24_hour_clock(double);
int get_hours(int);
int get_minutes(int);
int get_seconds(int);
double time_to_utc(int, double);
double time_from_utc(int, double);
55 changes: 55 additions & 0 deletions EXTRATASK1/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <iostream>
#include <cassert>
#include <cmath>
#include "extra-task-1.h"

int main()
{
// Тесты для seconds_difference
assert(fabs(seconds_difference(1800.0, 3600.0) - 1800.0) < DBL_EPSILON);
assert(fabs(seconds_difference(3600.0, 1800.0) - (-1800.0)) < DBL_EPSILON);
assert(fabs(seconds_difference(1800.0, 2160.0) - 360.0) < DBL_EPSILON);
assert(fabs(seconds_difference(1800.0, 1800.0) - 0.0) < DBL_EPSILON);

// Тесты для hours_difference
assert(fabs(hours_difference(1800.0, 3600.0) - 0.5) < DBL_EPSILON);
assert(fabs(hours_difference(3600.0, 1800.0) - (-0.5)) < DBL_EPSILON);
assert(fabs(hours_difference(1800.0, 2160.0) - 0.1) < DBL_EPSILON);
assert(fabs(hours_difference(1800.0, 1800.0) - 0.0) < DBL_EPSILON);

// Тесты для to_float_hours
assert(fabs(to_float_hours(0, 15, 0) - 0.25) < DBL_EPSILON);
assert(fabs(to_float_hours(2, 45, 9) - 2.7525) < DBL_EPSILON);
assert(fabs(to_float_hours(1, 0, 36) - 1.01) < DBL_EPSILON);

// Тесты для to_24_hour_clock
assert(fabs(to_24_hour_clock(24) - 0.0) < DBL_EPSILON);
assert(fabs(to_24_hour_clock(48) - 0.0) < DBL_EPSILON);
assert(fabs(to_24_hour_clock(25) - 1.0) < DBL_EPSILON);
assert(fabs(to_24_hour_clock(4) - 4.0) < DBL_EPSILON);
assert(fabs(to_24_hour_clock(28.5) - 4.5) < DBL_EPSILON);

// Тесты для get_hours, get_minutes, get_seconds
assert(get_hours(3800) == 1);
assert(get_minutes(3800) == 3);
assert(get_seconds(3800) == 20);

// Тесты для time_to_utc
assert(fabs(time_to_utc(0, 12.0) - 12.0) < DBL_EPSILON);
assert(fabs(time_to_utc(1, 12.0) - 11.0) < DBL_EPSILON);
assert(fabs(time_to_utc(-1, 12.0) - 13.0) < DBL_EPSILON);
assert(fabs(time_to_utc(-11, 18.0) - 5.0) < DBL_EPSILON);
assert(fabs(time_to_utc(-1, 0.0) - 1.0) < DBL_EPSILON);
assert(fabs(time_to_utc(-1, 23.0) - 0.0) < DBL_EPSILON);

// Тесты для time_from_utc
assert(fabs(time_from_utc(0, 12.0) - 12.0) < DBL_EPSILON);
assert(fabs(time_from_utc(1, 12.0) - 13.0) < DBL_EPSILON);
assert(fabs(time_from_utc(-1, 12.0) - 11.0) < DBL_EPSILON);
assert(fabs(time_from_utc(6, 6.0) - 12.0) < DBL_EPSILON);
assert(fabs(time_from_utc(-7, 6.0) - 23.0) < DBL_EPSILON);
assert(fabs(time_from_utc(-1, 0.0) - 23.0) < DBL_EPSILON);
assert(fabs(time_from_utc(-1, 23.0) - 22.0) < DBL_EPSILON);
assert(fabs(time_from_utc(1, 23.0) - 0.0) < DBL_EPSILON);
}

Binary file added EXTRATASK1/x64/Debug/EXTRATASK1.exe
Binary file not shown.
Binary file added EXTRATASK1/x64/Debug/EXTRATASK1.pdb
Binary file not shown.
Loading