diff --git a/sem2/VasilevAD/hw3/hw3.sln b/sem2/VasilevAD/hw3/hw3.sln new file mode 100644 index 00000000..4d3f5c6b --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.37111.16 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hw3", "hw3\hw3.vcxproj", "{A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}" +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 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Debug|x64.ActiveCfg = Debug|x64 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Debug|x64.Build.0 = Debug|x64 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Debug|x86.ActiveCfg = Debug|Win32 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Debug|x86.Build.0 = Debug|Win32 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Release|x64.ActiveCfg = Release|x64 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Release|x64.Build.0 = Release|x64 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Release|x86.ActiveCfg = Release|Win32 + {A4F7A12F-6FEF-44BC-9AA1-C02D737B9882}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {75CD3F54-6B0C-46D5-AA37-99268B6ACA91} + EndGlobalSection +EndGlobal diff --git a/sem2/VasilevAD/hw3/hw3/hw3.vcxproj b/sem2/VasilevAD/hw3/hw3/hw3.vcxproj new file mode 100644 index 00000000..50b2a376 --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/hw3.vcxproj @@ -0,0 +1,131 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {a4f7a12f-6fef-44bc-9aa1-c02d737b9882} + hw3 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + + + + + \ No newline at end of file diff --git a/sem2/VasilevAD/hw3/hw3/hw3.vcxproj.filters b/sem2/VasilevAD/hw3/hw3/hw3.vcxproj.filters new file mode 100644 index 00000000..3cb3d8b9 --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/hw3.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file diff --git a/sem2/VasilevAD/hw3/hw3/hw3.vcxproj.user b/sem2/VasilevAD/hw3/hw3/hw3.vcxproj.user new file mode 100644 index 00000000..0f14913f --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/hw3.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sem2/VasilevAD/hw3/hw3/input.txt b/sem2/VasilevAD/hw3/hw3/input.txt new file mode 100644 index 00000000..e2ba1fb0 --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/input.txt @@ -0,0 +1,6 @@ +Hello world +C++ programming is fun +Lambda expressions +STL algorithms +Short +A very long string just for testing purposes \ No newline at end of file diff --git a/sem2/VasilevAD/hw3/hw3/main.cpp b/sem2/VasilevAD/hw3/hw3/main.cpp new file mode 100644 index 00000000..34024f19 --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/main.cpp @@ -0,0 +1,115 @@ +#include +#include +#include +#include +#include +#include + + +int main() { + std::ifstream in_file("input.txt"); + if (!in_file.is_open()) { + std::cerr << "Failed to open input.txt\n"; + return 1; + } + + std::vector original_lines; + std::string current_line; + while (std::getline(in_file, current_line)) { + original_lines.push_back(current_line); + } + in_file.close(); + + // + size_t length_threshold = 0; + std::cout << "Enter the minimum string length threshold: "; + std::cin >> length_threshold; + + std::string search_word; + std::cout << "Enter the word to search for: "; + std::cin >> search_word; + + std::ofstream out_file("output.txt"); + if (!out_file.is_open()) { + std::cerr << "Failed to open output.txt\n"; + return 1; + } + + // + std::vector working_lines = original_lines; + + + printVectorString(out_file, working_lines, "Original strings"); + + // ( ) + working_lines.erase(std::remove_if(working_lines.begin(), working_lines.end(), + [length_threshold](const std::string& s) { + return s.length() < length_threshold; }), + working_lines.end()); + + printVectorString(out_file, working_lines, "After removing short strings"); + + // + std::for_each(working_lines.begin(), working_lines.end(), [](std::string& s) { + std::replace(s.begin(), s.end(), ' ', '_'); + }); + + printVectorString(out_file, working_lines, "After replacing spaces with '_'"); + + // + auto found_it = std::find_if(working_lines.begin(), working_lines.end(), + [&search_word](const std::string& s) { + return s.find(search_word) != std::string::npos; + }); + + out_file << "--- Search result for word '" << search_word << "' ---\n"; + if (found_it != working_lines.end()) { + out_file << "Found in string: " << *found_it << "\n\n"; + } else { + out_file << "Word not found.\n\n"; + } + + // + int char_count = std::accumulate( + working_lines.begin(), working_lines.end(), 0, + [](int current_sum, const std::string& s) { + return current_sum + std::count_if(s.begin(), s.end(), + [](char c) { return c != '_'; }); + }); + + out_file << "--- Total characters excluding '_' ---\n"; + out_file << char_count << "\n\n"; + + // + std::vector lengths; + lengths.reserve(working_lines.size()); + std::transform( + working_lines.begin(), working_lines.end(), std::back_inserter(lengths), + [](const std::string& s) { return static_cast(s.length()); }); + + printVectorInt(out_file, lengths, "Lengths of strings"); + + out_file.close(); + std::cout << "Processing complete. Results are saved in output.txt\n"; + + return 0; +} + + +void printVectorString(std::ofstream& out, const std::vector& vec, + const std::string& title) { + out << "--- " << title << " ---\n"; + for (const auto& str : vec) { + out << str << "\n"; + } + out << "\n"; +} + +void printVectorInt(std::ofstream& out, const std::vector& vec, + const std::string& title) { + out << "--- " << title << " ---\n"; + for (const auto& val : vec) { + out << val << " "; + } + out << "\n\n"; +} \ No newline at end of file diff --git a/sem2/VasilevAD/hw3/hw3/output.txt b/sem2/VasilevAD/hw3/hw3/output.txt new file mode 100644 index 00000000..7b76c7dc --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/output.txt @@ -0,0 +1,31 @@ +--- Original strings --- +Hello world +C++ programming is fun +Lambda expressions +STL algorithms +Short +A very long string just for testing purposes + +--- After removing short strings --- +Hello world +C++ programming is fun +Lambda expressions +STL algorithms +A very long string just for testing purposes + +--- After replacing spaces with '_' --- +Hello_world +C++_programming_is_fun +Lambda_expressions +STL_algorithms +A_very_long_string_just_for_testing_purposes + +--- Search result for word 'fun' --- +Found in string: C++_programming_is_fun + +--- Total characters excluding '_' --- +96 + +--- Lengths of strings --- +11 22 18 14 44 + diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.exe.recipe b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.exe.recipe new file mode 100644 index 00000000..4b6e586b --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.exe.recipe @@ -0,0 +1,11 @@ + + + + + C:\Users\Weyd\Desktop\hw3\x64\Debug\hw3.exe + + + + + + \ No newline at end of file diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.ilk b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.ilk new file mode 100644 index 00000000..d4c9c9fb Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.ilk differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.log b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.log new file mode 100644 index 00000000..a3732b82 --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.log @@ -0,0 +1,19 @@ + main.cpp +C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\numeric(33,26): warning C4244: =: преобразование "__int64" в "_Ty", возможна потеря данных +C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\numeric(33,26): warning C4244: with +C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\numeric(33,26): warning C4244: [ +C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\numeric(33,26): warning C4244: _Ty=int +C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\numeric(33,26): warning C4244: ] + (компиляция исходного файла "main.cpp") + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\numeric(33,26): + контекст создания экземпляра шаблона (сначала самый старый) + C:\Users\Weyd\Desktop\hw3\hw3\main.cpp(94,25): + выполняется компиляция ссылки на экземпляр шаблон функции "_Ty std::accumulate,std::allocator>>>>,int,main::>(const _InIt,const _InIt,_Ty,_Fn)" + with + [ + _Ty=int, + _InIt=std::_Vector_iterator>>, + _Fn=main:: + ] + + hw3.vcxproj -> C:\Users\Weyd\Desktop\hw3\x64\Debug\hw3.exe diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.command.1.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.command.1.tlog new file mode 100644 index 00000000..8eeaae99 Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.command.1.tlog differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.read.1.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.read.1.tlog new file mode 100644 index 00000000..4d7443cc Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.read.1.tlog differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.write.1.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.write.1.tlog new file mode 100644 index 00000000..ac1de112 Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/CL.write.1.tlog differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/Cl.items.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/Cl.items.tlog new file mode 100644 index 00000000..246cc91d --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/Cl.items.tlog @@ -0,0 +1 @@ +C:\Users\Weyd\Desktop\hw3\hw3\main.cpp;C:\Users\Weyd\Desktop\hw3\hw3\x64\Debug\main.obj diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/hw3.lastbuildstate b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/hw3.lastbuildstate new file mode 100644 index 00000000..e393c2c7 --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/hw3.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.44.35207:TargetPlatformVersion=10.0.26100.0: +Debug|x64|C:\Users\Weyd\Desktop\hw3\| diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.command.1.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.command.1.tlog new file mode 100644 index 00000000..d5239046 Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.command.1.tlog differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.read.1.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.read.1.tlog new file mode 100644 index 00000000..51680fbd Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.read.1.tlog differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.secondary.1.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.secondary.1.tlog new file mode 100644 index 00000000..150be0f4 --- /dev/null +++ b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.secondary.1.tlog @@ -0,0 +1,2 @@ +^C:\USERS\WEYD\DESKTOP\HW3\HW3\X64\DEBUG\MAIN.OBJ +C:\Users\Weyd\Desktop\hw3\hw3\x64\Debug\hw3.ilk diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.write.1.tlog b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.write.1.tlog new file mode 100644 index 00000000..4556f485 Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/hw3.tlog/link.write.1.tlog differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/main.obj b/sem2/VasilevAD/hw3/hw3/x64/Debug/main.obj new file mode 100644 index 00000000..9462b79b Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/main.obj differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/vc143.idb b/sem2/VasilevAD/hw3/hw3/x64/Debug/vc143.idb new file mode 100644 index 00000000..97a01d78 Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/vc143.idb differ diff --git a/sem2/VasilevAD/hw3/hw3/x64/Debug/vc143.pdb b/sem2/VasilevAD/hw3/hw3/x64/Debug/vc143.pdb new file mode 100644 index 00000000..e9144285 Binary files /dev/null and b/sem2/VasilevAD/hw3/hw3/x64/Debug/vc143.pdb differ diff --git a/sem2/VasilevAD/hw3/x64/Debug/hw3.exe b/sem2/VasilevAD/hw3/x64/Debug/hw3.exe new file mode 100644 index 00000000..f8900a11 Binary files /dev/null and b/sem2/VasilevAD/hw3/x64/Debug/hw3.exe differ diff --git a/sem2/VasilevAD/hw3/x64/Debug/hw3.pdb b/sem2/VasilevAD/hw3/x64/Debug/hw3.pdb new file mode 100644 index 00000000..1e938c4c Binary files /dev/null and b/sem2/VasilevAD/hw3/x64/Debug/hw3.pdb differ