From 87c3ae0e24f9b04121e862314f466d34d7724181 Mon Sep 17 00:00:00 2001 From: "savelev.g" Date: Thu, 26 Dec 2024 09:08:25 +0400 Subject: [PATCH] 1 --- 22/ConsoleApplication1/ConsoleApplication1.c | 62 ++++++++ .../ConsoleApplication1.sln | 31 ++++ .../ConsoleApplication1.vcxproj | 135 ++++++++++++++++++ .../ConsoleApplication1.vcxproj.filters | 22 +++ 4 files changed, 250 insertions(+) create mode 100644 22/ConsoleApplication1/ConsoleApplication1.c create mode 100644 22/ConsoleApplication1/ConsoleApplication1.sln create mode 100644 22/ConsoleApplication1/ConsoleApplication1.vcxproj create mode 100644 22/ConsoleApplication1/ConsoleApplication1.vcxproj.filters diff --git a/22/ConsoleApplication1/ConsoleApplication1.c b/22/ConsoleApplication1/ConsoleApplication1.c new file mode 100644 index 0000000..4095eda --- /dev/null +++ b/22/ConsoleApplication1/ConsoleApplication1.c @@ -0,0 +1,62 @@ +#include + +int strlen_1st(char c[]) { + int result = 0; + do { result += 1; } while (c[result] != '\0'); + return result; +} + +int strlen_2nd(char c[]) { + char* p = c; + while (*p++); return p - c - 1; +} + +int strcmp_1st(char s1[], char s2[]) { + int len1 = 0, len2 = 0, i = 0; + while (len1 == 0 || len2 == 0) { + if (len1 == 0 && s1[i] == '\0') { len1 = i; } + else if (len2 == 0 && s2[i] == '\0') { len2 = i; } + i++; + } + return len1 - len2; +} + +void strcpy(char s1[], char d1[]) { + for (int i = 0; i < 9999; i++) { + if (s1[i] != '\0') { + d1[i] = s1[i]; + } + else { + break; + } + } +} + +void strcat_1st(char* s1, char* s2) { + while (*s2) s2++; + while (*s2++ == *s1++); +} + +int strchr(char s1[], char sym) { + int i = 0; + while (s1[i] != sym) { + i++; + if (i >= strlen_1st(s1)) { printf("there's no such symbol"); break; } + } + return i; +} + +void main() { + char str[11] = "string"; + char str2[12] = "string2"; + char str3[13] = "stringthree"; + char strx[11] = "string4"; + char etp[14] = ""; + char* Word; + printf("%d\n", strlen_1st(str)); + printf("%d\n", strlen_2nd(str2)); + printf("%d %d\n", strcmp_1st(str, str2), strcmp_1st(str, str3)); + strcpy(str, etp); printf("%s\n", etp); + strcat(str3, etp); printf("%s\n", str3); + printf("n at index %d - in %s\nf", strchr(strx, 'n'), strx); +} \ No newline at end of file diff --git a/22/ConsoleApplication1/ConsoleApplication1.sln b/22/ConsoleApplication1/ConsoleApplication1.sln new file mode 100644 index 0000000..bd7980f --- /dev/null +++ b/22/ConsoleApplication1/ConsoleApplication1.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "ConsoleApplication1.vcxproj", "{8768DC0F-A76E-440B-B442-E6F06EB6DE7A}" +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 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Debug|x64.ActiveCfg = Debug|x64 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Debug|x64.Build.0 = Debug|x64 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Debug|x86.ActiveCfg = Debug|Win32 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Debug|x86.Build.0 = Debug|Win32 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Release|x64.ActiveCfg = Release|x64 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Release|x64.Build.0 = Release|x64 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Release|x86.ActiveCfg = Release|Win32 + {8768DC0F-A76E-440B-B442-E6F06EB6DE7A}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {41341111-547D-4EC2-9D13-0292C029FF47} + EndGlobalSection +EndGlobal diff --git a/22/ConsoleApplication1/ConsoleApplication1.vcxproj b/22/ConsoleApplication1/ConsoleApplication1.vcxproj new file mode 100644 index 0000000..e0be3b4 --- /dev/null +++ b/22/ConsoleApplication1/ConsoleApplication1.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {8768dc0f-a76e-440b-b442-e6f06eb6de7a} + ConsoleApplication1 + 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 + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/22/ConsoleApplication1/ConsoleApplication1.vcxproj.filters b/22/ConsoleApplication1/ConsoleApplication1.vcxproj.filters new file mode 100644 index 0000000..ff67cec --- /dev/null +++ b/22/ConsoleApplication1/ConsoleApplication1.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