buborek rendezes
This commit is contained in:
parent
b5ae918593
commit
306c0efbb7
Binary file not shown.
BIN
20241212/ConsoleApp1/.vs/ConsoleApp1/v17/.suo
Normal file
BIN
20241212/ConsoleApp1/.vs/ConsoleApp1/v17/.suo
Normal file
Binary file not shown.
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp1\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}|ConsoleApp1\\ConsoleApp1.csproj|c:\\users\\szabomarton\\desktop\\c#\\progaora\\20241212\\consoleapp1\\consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||
"RelativeDocumentMoniker": "ConsoleApp1\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||
"RelativeToolTip": "ConsoleApp1\\Program.cs",
|
||||
"ViewState": "AgIAAIQAAAAAAAAAAAAowJsAAAAxAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-12-12T07:05:23.632Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
37
20241212/ConsoleApp1/.vs/ConsoleApp1/v17/DocumentLayout.json
Normal file
37
20241212/ConsoleApp1/.vs/ConsoleApp1/v17/DocumentLayout.json
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp1\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}|ConsoleApp1\\ConsoleApp1.csproj|c:\\users\\szabomarton\\desktop\\c#\\progaora\\20241212\\consoleapp1\\consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}|ConsoleApp1\\ConsoleApp1.csproj|solutionrelative:consoleapp1\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||
"RelativeDocumentMoniker": "ConsoleApp1\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp1\\ConsoleApp1\\Program.cs",
|
||||
"RelativeToolTip": "ConsoleApp1\\Program.cs",
|
||||
"ViewState": "AgIAAIQAAAAAAAAAAAAowJsAAAAxAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-12-12T07:05:23.632Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
25
20241212/ConsoleApp1/ConsoleApp1.sln
Normal file
25
20241212/ConsoleApp1/ConsoleApp1.sln
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35222.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0A8C4998-196A-47C7-893D-1CB2F85DF795}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
6
20241212/ConsoleApp1/ConsoleApp1/App.config
Normal file
6
20241212/ConsoleApp1/ConsoleApp1/App.config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
53
20241212/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj
Normal file
53
20241212/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{00E423C5-BAB5-4A54-B15C-7A3BDDCB868F}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ConsoleApp1</RootNamespace>
|
||||
<AssemblyName>ConsoleApp1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
173
20241212/ConsoleApp1/ConsoleApp1/Program.cs
Normal file
173
20241212/ConsoleApp1/ConsoleApp1/Program.cs
Normal file
|
@ -0,0 +1,173 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
public static class AOC
|
||||
{
|
||||
public static List<int> first = new List<int>();
|
||||
public static List<int> second = new List<int>();
|
||||
}
|
||||
internal class Program
|
||||
{
|
||||
public static int Binariskeres(int[] tomb, int keresettertek)
|
||||
{
|
||||
int eleje = 0;
|
||||
int vege = tomb.Length - 1;
|
||||
while (eleje <= vege)
|
||||
{
|
||||
int i = (eleje + vege) / 2;
|
||||
if (tomb[i] == keresettertek)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
else if (tomb[i] < keresettertek)
|
||||
{
|
||||
eleje = i + 1;
|
||||
}
|
||||
else if (tomb[i] > keresettertek)
|
||||
{
|
||||
vege = i - 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int BinariskeresRekurziv(int[] tomb, int keresettertek, int eleje, int vege)
|
||||
{
|
||||
int mid = (eleje + vege) / 2;
|
||||
if (vege < 1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tomb[mid] == keresettertek) { return mid; }
|
||||
if (tomb[mid] > keresettertek)
|
||||
{
|
||||
return BinariskeresRekurziv(tomb, keresettertek, eleje, mid - 1);
|
||||
}
|
||||
|
||||
return BinariskeresRekurziv(tomb, keresettertek, mid + 1, vege);
|
||||
}
|
||||
|
||||
public static void Orai()
|
||||
{
|
||||
var tomb = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
|
||||
int index = Binariskeres(tomb, 8);
|
||||
int index2 = BinariskeresRekurziv(tomb, 1, 0, tomb.Length);
|
||||
int index3 = Binariskeres(tomb, 18); //-1, mert nincs ilyen
|
||||
//int index = Array.BinarySearch(tomb, 8);
|
||||
|
||||
Console.WriteLine("A nyolcas indexe: {0}", index);
|
||||
Console.WriteLine("Az egyes indexe: {0}", index2);
|
||||
Console.WriteLine("Az 18 indexe: {0}", index3);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
public static void ReadingInput(string path)
|
||||
{
|
||||
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
StreamReader streamReader = new StreamReader(fileStream);
|
||||
|
||||
string line = streamReader.ReadLine();
|
||||
while (line != null)
|
||||
{
|
||||
string[] parts = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int value1 = Convert.ToInt32(parts[0]);
|
||||
int value2 = Convert.ToInt32(parts[1]);
|
||||
|
||||
AOC.first.Add(value1);
|
||||
AOC.second.Add(value2);
|
||||
|
||||
line = streamReader.ReadLine();
|
||||
}
|
||||
|
||||
streamReader.Close();
|
||||
fileStream.Close();
|
||||
}
|
||||
|
||||
public static void BubiSort()
|
||||
{
|
||||
int[] t = new int[] { 5,4,4,8,73,4,58,4,3,78,2,84,456,69};
|
||||
int n = t.Length;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
Console.WriteLine($"{t[i]}");
|
||||
}
|
||||
|
||||
for (int i = n -1;i > 0; i--)
|
||||
{
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
if (t[j] > t[j+1])
|
||||
{
|
||||
int tmp = t[j + 1];
|
||||
t[j+1] = t[j];
|
||||
t[j] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] Buborekrendezes(int[] bemenet)
|
||||
{
|
||||
int[] tomb = new int[bemenet.Length];
|
||||
Array.Copy(bemenet, tomb, bemenet.Length);
|
||||
|
||||
var csere = true;
|
||||
|
||||
for (int i = tomb.Length - 1; i >= 0 && csere; i--)
|
||||
{
|
||||
csere = false;
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
if (tomb[j] > tomb[j + 1])
|
||||
{
|
||||
int tmp = tomb[j];
|
||||
tomb[j] = tomb[j + 1];
|
||||
tomb[j + 1] = tmp;
|
||||
csere = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tomb;
|
||||
}
|
||||
|
||||
public static void AOC_1(int[] array1, int[] array2)
|
||||
{
|
||||
List<int> differences = new List<int>();
|
||||
|
||||
for (int i = 0; i < array1.Length; i++)
|
||||
{
|
||||
|
||||
int diff = Math.Abs(array1[i] - array2[i]);
|
||||
differences.Add(diff);
|
||||
//Console.WriteLine(diff);
|
||||
|
||||
//Console.WriteLine($"{array1[i]} - {array2[i]} = {diff}");
|
||||
}
|
||||
|
||||
Console.WriteLine(differences.Sum());
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string path = $@"C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\input.txt";
|
||||
ReadingInput(path);
|
||||
|
||||
AOC.first.Sort();
|
||||
AOC.second.Sort();
|
||||
|
||||
AOC_1(AOC.first.ToArray(), AOC.second.ToArray());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
33
20241212/ConsoleApp1/ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
33
20241212/ConsoleApp1/ConsoleApp1/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ConsoleApp1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ConsoleApp1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("00e423c5-bab5-4a54-b15c-7a3bddcb868f")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
BIN
20241212/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe
Normal file
BIN
20241212/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.exe
Normal file
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
BIN
20241212/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.pdb
Normal file
BIN
20241212/ConsoleApp1/ConsoleApp1/bin/Debug/ConsoleApp1.pdb
Normal file
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
137ddb1975586287657f37337b64d051167bb6a147915d9fb5b8eb94b1093509
|
|
@ -0,0 +1,7 @@
|
|||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.exe.config
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.exe
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.pdb
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.AssemblyReference.cache
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.CoreCompileInputs.cache
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.exe
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp1\ConsoleApp1\obj\Debug\ConsoleApp1.pdb
|
BIN
20241212/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.exe
Normal file
BIN
20241212/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.exe
Normal file
Binary file not shown.
BIN
20241212/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.pdb
Normal file
BIN
20241212/ConsoleApp1/ConsoleApp1/obj/Debug/ConsoleApp1.pdb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
20241212/ConsoleApp2/.vs/ConsoleApp2/v17/.suo
Normal file
BIN
20241212/ConsoleApp2/.vs/ConsoleApp2/v17/.suo
Normal file
Binary file not shown.
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp2\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{552418A1-8D09-4931-BCAC-F8DE2494CC65}|ConsoleApp2\\ConsoleApp2.csproj|c:\\users\\szabomarton\\desktop\\c#\\progaora\\20241212\\consoleapp2\\consoleapp2\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{552418A1-8D09-4931-BCAC-F8DE2494CC65}|ConsoleApp2\\ConsoleApp2.csproj|solutionrelative:consoleapp2\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp2\\ConsoleApp2\\Program.cs",
|
||||
"RelativeDocumentMoniker": "ConsoleApp2\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp2\\ConsoleApp2\\Program.cs",
|
||||
"RelativeToolTip": "ConsoleApp2\\Program.cs",
|
||||
"ViewState": "AgIAAFQAAAAAAAAAAAAAAFcAAAAfAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-12-12T08:24:47.98Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
37
20241212/ConsoleApp2/.vs/ConsoleApp2/v17/DocumentLayout.json
Normal file
37
20241212/ConsoleApp2/.vs/ConsoleApp2/v17/DocumentLayout.json
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp2\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{552418A1-8D09-4931-BCAC-F8DE2494CC65}|ConsoleApp2\\ConsoleApp2.csproj|c:\\users\\szabomarton\\desktop\\c#\\progaora\\20241212\\consoleapp2\\consoleapp2\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{552418A1-8D09-4931-BCAC-F8DE2494CC65}|ConsoleApp2\\ConsoleApp2.csproj|solutionrelative:consoleapp2\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp2\\ConsoleApp2\\Program.cs",
|
||||
"RelativeDocumentMoniker": "ConsoleApp2\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\C#\\ProgaOra\\20241212\\ConsoleApp2\\ConsoleApp2\\Program.cs",
|
||||
"RelativeToolTip": "ConsoleApp2\\Program.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA4AAAA4AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2024-12-12T08:24:47.98Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
25
20241212/ConsoleApp2/ConsoleApp2.sln
Normal file
25
20241212/ConsoleApp2/ConsoleApp2.sln
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35222.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{552418A1-8D09-4931-BCAC-F8DE2494CC65}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{552418A1-8D09-4931-BCAC-F8DE2494CC65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{552418A1-8D09-4931-BCAC-F8DE2494CC65}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{552418A1-8D09-4931-BCAC-F8DE2494CC65}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{552418A1-8D09-4931-BCAC-F8DE2494CC65}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F7356D07-2DD6-4639-9873-1CF4F8FE8C2A}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
6
20241212/ConsoleApp2/ConsoleApp2/App.config
Normal file
6
20241212/ConsoleApp2/ConsoleApp2/App.config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
53
20241212/ConsoleApp2/ConsoleApp2/ConsoleApp2.csproj
Normal file
53
20241212/ConsoleApp2/ConsoleApp2/ConsoleApp2.csproj
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{552418A1-8D09-4931-BCAC-F8DE2494CC65}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>ConsoleApp2</RootNamespace>
|
||||
<AssemblyName>ConsoleApp2</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
111
20241212/ConsoleApp2/ConsoleApp2/Program.cs
Normal file
111
20241212/ConsoleApp2/ConsoleApp2/Program.cs
Normal file
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConsoleApp2
|
||||
{
|
||||
public static class AOC
|
||||
{
|
||||
public static List<int> first = new List<int>();
|
||||
public static List<int> second = new List<int>();
|
||||
public static Dictionary<int, int> keyValuePairs = new Dictionary<int, int>();
|
||||
}
|
||||
|
||||
|
||||
internal class Program
|
||||
{
|
||||
public static void ReadingInput(string path)
|
||||
{
|
||||
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
||||
StreamReader streamReader = new StreamReader(fileStream);
|
||||
|
||||
string line = streamReader.ReadLine();
|
||||
while (line != null)
|
||||
{
|
||||
string[] parts = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int value1 = Convert.ToInt32(parts[0]);
|
||||
int value2 = Convert.ToInt32(parts[1]);
|
||||
|
||||
AOC.first.Add(value1);
|
||||
AOC.second.Add(value2);
|
||||
|
||||
line = streamReader.ReadLine();
|
||||
}
|
||||
|
||||
streamReader.Close();
|
||||
fileStream.Close();
|
||||
}
|
||||
|
||||
public static void AOC_2(int[] array1, int[] array2)
|
||||
{
|
||||
foreach (var item in array1)
|
||||
{
|
||||
if (AOC.keyValuePairs.ContainsKey(item))
|
||||
{
|
||||
if (array2.Contains(item))
|
||||
{
|
||||
int num = array2.Count(x => x == item);
|
||||
AOC.keyValuePairs[item] += num;
|
||||
}
|
||||
else
|
||||
{
|
||||
AOC.keyValuePairs.Add(item, 0);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (array2.Contains(item))
|
||||
{
|
||||
int num = array2.Count(x => x == item);
|
||||
AOC.keyValuePairs.Add(item, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
AOC.keyValuePairs.Add(item, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int sol = 0;
|
||||
|
||||
foreach (var item in AOC.keyValuePairs)
|
||||
{
|
||||
sol += item.Key * item.Value;
|
||||
Console.WriteLine($"{item.Key} - {item.Value}");
|
||||
}
|
||||
|
||||
Console.WriteLine(sol);
|
||||
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
string path = $@"C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\input.txt";
|
||||
ReadingInput(path);
|
||||
|
||||
/*
|
||||
AOC.first.Add(3);
|
||||
AOC.first.Add(4);
|
||||
AOC.first.Add(2);
|
||||
AOC.first.Add(1);
|
||||
AOC.first.Add(3);
|
||||
AOC.first.Add(3);
|
||||
|
||||
AOC.second.Add(4);
|
||||
AOC.second.Add(3);
|
||||
AOC.second.Add(5);
|
||||
AOC.second.Add(3);
|
||||
AOC.second.Add(9);
|
||||
AOC.second.Add(3);
|
||||
*/
|
||||
AOC.first.Sort();
|
||||
AOC.second.Sort();
|
||||
|
||||
AOC_2(AOC.first.ToArray(), AOC.second.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
33
20241212/ConsoleApp2/ConsoleApp2/Properties/AssemblyInfo.cs
Normal file
33
20241212/ConsoleApp2/ConsoleApp2/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ConsoleApp2")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ConsoleApp2")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("552418a1-8d09-4931-bcac-f8de2494cc65")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
BIN
20241212/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe
Normal file
BIN
20241212/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.exe
Normal file
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
BIN
20241212/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.pdb
Normal file
BIN
20241212/ConsoleApp2/ConsoleApp2/bin/Debug/ConsoleApp2.pdb
Normal file
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
137ddb1975586287657f37337b64d051167bb6a147915d9fb5b8eb94b1093509
|
|
@ -0,0 +1,7 @@
|
|||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp2\ConsoleApp2\bin\Debug\ConsoleApp2.exe.config
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp2\ConsoleApp2\bin\Debug\ConsoleApp2.exe
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp2\ConsoleApp2\bin\Debug\ConsoleApp2.pdb
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.csproj.AssemblyReference.cache
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.csproj.CoreCompileInputs.cache
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.exe
|
||||
C:\Users\szabomarton\Desktop\C#\ProgaOra\20241212\ConsoleApp2\ConsoleApp2\obj\Debug\ConsoleApp2.pdb
|
BIN
20241212/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.exe
Normal file
BIN
20241212/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.exe
Normal file
Binary file not shown.
BIN
20241212/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.pdb
Normal file
BIN
20241212/ConsoleApp2/ConsoleApp2/obj/Debug/ConsoleApp2.pdb
Normal file
Binary file not shown.
Binary file not shown.
1000
20241212/input.txt
Normal file
1000
20241212/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
20241212/Órai1212.pdf
Normal file
BIN
20241212/Órai1212.pdf
Normal file
Binary file not shown.
|
@ -336,3 +336,32 @@ Hashmaps alapjai
|
|||
Fontos azonban megjegyezni, hogy a tényleges teljesítmény olyan tényezőktől függően változhat, mint az elemek száma, a hash kód ütközései és a terhalési tényező.
|
||||
|
||||
|
||||
Bináris Keresés
|
||||
|
||||
A bináris - más néven logaritmikus vagy felező módszer -
|
||||
mivel n elem esetén log(n) futási idővel rendelkezik.
|
||||
|
||||
A bináris keresés egy erősen optimalizált keresési eljárás,
|
||||
amely csak rendezett adatsoron alkalmazható.
|
||||
Pélédául, amikor egy nyomtatott szótárban keresünk egy szót vagy jelenléti íven keressük a nevünket.
|
||||
A keresett értéket egy mintaadattal összehasonlítjuk és az eredménytől függően - amennyire lehet -
|
||||
egy nagy részt kizárunk a tartományból.
|
||||
|
||||
A módszer külön implementációt nem igényel, mivel az Array és a list osztály os tartalmaz bináris keresésre implementációt.
|
||||
|
||||
int index = Array.BinarySearch(Array array, object value);
|
||||
|
||||
Buborékrendezés
|
||||
|
||||
A rendezés során a tömb fennmaradó részén végighaladva az egymás utáni szomszédos elemeket összehasonlítjuk, és ha szükséges, megcseréljük őket, hogy közölük mindig a nagyobb helyezkedjen el feljebb.
|
||||
|
||||
Pszeudokód:
|
||||
Ciklus i = 6 -tól 1-ig
|
||||
Ciklus j = 0-tól i-1-ig
|
||||
Ha a[j] > a [j+1] AKKOR
|
||||
csere a[j] a[j+1]
|
||||
|
||||
Az algoritmusnak csak akkor van értelme tovább futnia, ha a belső ciklusban volt csere.
|
||||
|
||||
A javított algoritmus futási ideje legjobb esetben lineáris lesz,
|
||||
legrosszabb esetben pedig négyzetes.
|
||||
|
|
Loading…
Reference in New Issue
Block a user