diff --git a/fordulo_1/Program/Program.cs b/fordulo_1/Program/Program.cs index 4361a5c..44a5295 100644 --- a/fordulo_1/Program/Program.cs +++ b/fordulo_1/Program/Program.cs @@ -147,6 +147,88 @@ public static class Szoveg{ { return wordsWithUniqeCharactersOnly.OrderByDescending(s => s.Length).First(); } + + public static int GreatestDistanceBetweenWords(string input) + { + int maxDistance = 0; + int? firstIndex = null; + + int firstEndIndex = 0; + int? secondIndex = null; + int secondStartIndex = 0; + int secondEndIndex = 0; + + for (int i = 1; i < input.Length - 2; i++) + { + // új névelő megtalálva + if (input[i] == 'A' && input[i - 1] == ' ' && input[i + 1] == ' ') + { + if (firstIndex == null) + { + firstIndex = i; + firstEndIndex = i; + continue; + } + + if (secondIndex == null && firstIndex != null) + { + secondIndex = i; + secondStartIndex = i; + secondEndIndex = i; + } + + // kettő közötti távolság + int distance = Convert.ToInt32(secondStartIndex - firstEndIndex - 1); + if (distance > maxDistance) + { + maxDistance = distance; + } + + firstIndex = secondIndex; + + firstEndIndex = secondEndIndex; + + secondIndex = i; + secondStartIndex = i; + secondEndIndex = i; + + continue; + } + + if (input [i] == 'A' && input[i + 1] == 'Z' && input[i - 1] == ' ' && input[i + 2] == ' '){ + if (firstIndex == null) + { + firstIndex = i; + firstEndIndex = i + 1; + continue; + } + + if (secondIndex == null && firstIndex != null) + { + secondIndex = i; + secondStartIndex = i; + secondEndIndex = i + 1; + } + + // kettő közötti távolság + int distance = Convert.ToInt32(secondStartIndex - firstEndIndex - 1); + if (distance > maxDistance) + { + maxDistance = distance; + } + + firstIndex = secondIndex; + + firstEndIndex = secondEndIndex; + + secondIndex = i; + secondStartIndex = i; + secondEndIndex = i + 1; + } + } + + return maxDistance; + } } public class Program @@ -178,11 +260,20 @@ public static class Szoveg{ // feladat 2 a - Szoveg.ReadDataFromFile(@"..\szoveg.txt"); + Szoveg.ReadDataFromFile(@"..\testinput.txt"); + /* Szoveg.wordsWithUniqeCharactersOnly = Szoveg.WordsWithUniqeCharactersOnly(); System.Console.WriteLine($"{Szoveg.LongestStringWithUniqueCharacters()}"); + */ + + // feladat 2 b + string fullTextInSingleString = string.Join(" ", Szoveg.fullTextInListOfString); + + int value = Szoveg.GreatestDistanceBetweenWords(fullTextInSingleString); + + System.Console.WriteLine($"{value}"); } } \ No newline at end of file diff --git a/fordulo_1/Program/bin/Debug/net9.0/Program.dll b/fordulo_1/Program/bin/Debug/net9.0/Program.dll index 34379e7..8b1f759 100644 Binary files a/fordulo_1/Program/bin/Debug/net9.0/Program.dll and b/fordulo_1/Program/bin/Debug/net9.0/Program.dll differ diff --git a/fordulo_1/Program/bin/Debug/net9.0/Program.exe b/fordulo_1/Program/bin/Debug/net9.0/Program.exe index d672c03..a41c019 100644 Binary files a/fordulo_1/Program/bin/Debug/net9.0/Program.exe and b/fordulo_1/Program/bin/Debug/net9.0/Program.exe differ diff --git a/fordulo_1/Program/bin/Debug/net9.0/Program.pdb b/fordulo_1/Program/bin/Debug/net9.0/Program.pdb index 68a73d9..c500acd 100644 Binary files a/fordulo_1/Program/bin/Debug/net9.0/Program.pdb and b/fordulo_1/Program/bin/Debug/net9.0/Program.pdb differ diff --git a/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfo.cs b/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfo.cs index f39174f..92f7b30 100644 --- a/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfo.cs +++ b/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Program")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2d3a3b5498848de0502de226cf3680344b851fa3")] [assembly: System.Reflection.AssemblyProductAttribute("Program")] [assembly: System.Reflection.AssemblyTitleAttribute("Program")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfoInputs.cache b/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfoInputs.cache index 206f331..ed0375e 100644 --- a/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfoInputs.cache +++ b/fordulo_1/Program/obj/Debug/net9.0/Program.AssemblyInfoInputs.cache @@ -1 +1 @@ -17a31eb238f6f175e91f757bce7478ca3439291fdf71caa540b0d35a4a757b14 +5f0e7be5aed498aebc515a122ed65f513d902cc336ac583393b795272d573e2f diff --git a/fordulo_1/Program/obj/Debug/net9.0/Program.GeneratedMSBuildEditorConfig.editorconfig b/fordulo_1/Program/obj/Debug/net9.0/Program.GeneratedMSBuildEditorConfig.editorconfig index 40cfe42..e1fa19e 100644 --- a/fordulo_1/Program/obj/Debug/net9.0/Program.GeneratedMSBuildEditorConfig.editorconfig +++ b/fordulo_1/Program/obj/Debug/net9.0/Program.GeneratedMSBuildEditorConfig.editorconfig @@ -8,7 +8,7 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Program -build_property.ProjectDir = E:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\ +build_property.ProjectDir = e:\Házi\13.osztály\Neumann_Verseny\fordulo_1\Program\ build_property.EnableComHosting = build_property.EnableGeneratedComInterfaceComImportInterop = build_property.EffectiveAnalysisLevelStyle = 9.0 diff --git a/fordulo_1/Program/obj/Debug/net9.0/Program.assets.cache b/fordulo_1/Program/obj/Debug/net9.0/Program.assets.cache index 6012cb7..4576458 100644 Binary files a/fordulo_1/Program/obj/Debug/net9.0/Program.assets.cache and b/fordulo_1/Program/obj/Debug/net9.0/Program.assets.cache differ diff --git a/fordulo_1/Program/obj/Debug/net9.0/Program.dll b/fordulo_1/Program/obj/Debug/net9.0/Program.dll index 34379e7..8b1f759 100644 Binary files a/fordulo_1/Program/obj/Debug/net9.0/Program.dll and b/fordulo_1/Program/obj/Debug/net9.0/Program.dll differ diff --git a/fordulo_1/Program/obj/Debug/net9.0/Program.pdb b/fordulo_1/Program/obj/Debug/net9.0/Program.pdb index 68a73d9..c500acd 100644 Binary files a/fordulo_1/Program/obj/Debug/net9.0/Program.pdb and b/fordulo_1/Program/obj/Debug/net9.0/Program.pdb differ diff --git a/fordulo_1/Program/obj/Debug/net9.0/apphost.exe b/fordulo_1/Program/obj/Debug/net9.0/apphost.exe index d672c03..a41c019 100644 Binary files a/fordulo_1/Program/obj/Debug/net9.0/apphost.exe and b/fordulo_1/Program/obj/Debug/net9.0/apphost.exe differ diff --git a/fordulo_1/Program/obj/Debug/net9.0/ref/Program.dll b/fordulo_1/Program/obj/Debug/net9.0/ref/Program.dll index de305c7..a6d1169 100644 Binary files a/fordulo_1/Program/obj/Debug/net9.0/ref/Program.dll and b/fordulo_1/Program/obj/Debug/net9.0/ref/Program.dll differ diff --git a/fordulo_1/Program/obj/Debug/net9.0/refint/Program.dll b/fordulo_1/Program/obj/Debug/net9.0/refint/Program.dll index de305c7..a6d1169 100644 Binary files a/fordulo_1/Program/obj/Debug/net9.0/refint/Program.dll and b/fordulo_1/Program/obj/Debug/net9.0/refint/Program.dll differ diff --git a/fordulo_1/testinput.txt b/fordulo_1/testinput.txt new file mode 100644 index 0000000..fb6a9fb --- /dev/null +++ b/fordulo_1/testinput.txt @@ -0,0 +1,2 @@ +HOL TEREM A M A GYAR VITEZ + AZ PATAKBAN KET GYERMEK FURDIK \ No newline at end of file