added fordulo_3 feladat_2 megoldas for a small input
This commit is contained in:
parent
7735a69f3c
commit
c83b7eacbd
fordulo_3
ProgVerseny_3_ford_2025.pdfApp.configProgram.csProgram.csprojProgram.sln
megoldasok.mdProgram
.vs/Program
CopilotIndices/17.13.431.34963
FileContentIndex
v17
Properties
Sorozat.csbin/Debug
obj/Debug
BIN
fordulo_3/ProgVerseny_3_ford_2025.pdf
Normal file
BIN
fordulo_3/ProgVerseny_3_ford_2025.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
fordulo_3/Program/.vs/Program/v17/.suo
Normal file
BIN
fordulo_3/Program/.vs/Program/v17/.suo
Normal file
Binary file not shown.
54
fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json
Normal file
54
fordulo_3/Program/.vs/Program/v17/DocumentLayout.backup.json
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Sorozat.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeDocumentMoniker": "Sorozat.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeToolTip": "Sorozat.cs",
|
||||
"ViewState": "AgIAAAgAAAAAAAAAAAAxwBkAAAAcAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:59:58.311Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAAQAAAAAAAAAAAAUwCEAAABqAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
54
fordulo_3/Program/.vs/Program/v17/DocumentLayout.json
Normal file
54
fordulo_3/Program/.vs/Program/v17/DocumentLayout.json
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:sorozat.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Sorozat.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeDocumentMoniker": "Sorozat.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Sorozat.cs",
|
||||
"RelativeToolTip": "Sorozat.cs",
|
||||
"ViewState": "AgIAAAgAAAAAAAAAAAAxwBkAAAAcAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:59:58.311Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAAQAAAAAAAAAAAAUwCEAAABqAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
6
fordulo_3/Program/App.config
Normal file
6
fordulo_3/Program/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.8" />
|
||||
</startup>
|
||||
</configuration>
|
37
fordulo_3/Program/Program.cs
Normal file
37
fordulo_3/Program/Program.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Program
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Sorozat leghosszabb = new Sorozat(77031);
|
||||
leghosszabb.TagokKiszamitasa(leghosszabb.KezdoErtek);
|
||||
|
||||
int max = 110000;
|
||||
int min = 100000;
|
||||
|
||||
|
||||
for (int i = min; i < max; i++)
|
||||
{
|
||||
Sorozat sorozat = new Sorozat(i);
|
||||
sorozat.TagokKiszamitasa(sorozat.KezdoErtek);
|
||||
if (sorozat.Tagok.Count > leghosszabb.Tagok.Count)
|
||||
{
|
||||
leghosszabb = new Sorozat(sorozat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// mivel 1.000.000 számot kell megvizsgálin ezért ez a fajta megoldás nem jó
|
||||
//Sorozat leghosszabb = sorozatok.OrderByDescending(x => x.Tagok.Count).First();
|
||||
|
||||
Console.WriteLine($"2. feladat megoldás: {leghosszabb.KezdoErtek}|{leghosszabb.Tagok.Count}");
|
||||
}
|
||||
}
|
||||
}
|
54
fordulo_3/Program/Program.csproj
Normal file
54
fordulo_3/Program/Program.csproj
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?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>{6A74A9DE-500D-46FF-859A-18F4A752D2A5}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Program</RootNamespace>
|
||||
<AssemblyName>Program</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</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" />
|
||||
<Compile Include="Sorozat.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
25
fordulo_3/Program/Program.sln
Normal file
25
fordulo_3/Program/Program.sln
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35818.85 d17.13
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Program", "Program.csproj", "{6A74A9DE-500D-46FF-859A-18F4A752D2A5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6A74A9DE-500D-46FF-859A-18F4A752D2A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6A74A9DE-500D-46FF-859A-18F4A752D2A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6A74A9DE-500D-46FF-859A-18F4A752D2A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6A74A9DE-500D-46FF-859A-18F4A752D2A5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {66F1EDAE-14B5-40E6-A725-9281D19AFDF6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
33
fordulo_3/Program/Properties/AssemblyInfo.cs
Normal file
33
fordulo_3/Program/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("Program")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Program")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||
[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("6a74a9de-500d-46ff-859a-18f4a752d2a5")]
|
||||
|
||||
// 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")]
|
71
fordulo_3/Program/Sorozat.cs
Normal file
71
fordulo_3/Program/Sorozat.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Program
|
||||
{
|
||||
class Sorozat
|
||||
{
|
||||
public int KezdoErtek;
|
||||
|
||||
public List<int> Tagok = new List<int>();
|
||||
|
||||
int[] kettoHatvanyok = new int[] { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608 };
|
||||
|
||||
public int TagokKiszamitasa(int ertek)
|
||||
{
|
||||
int ujertek;
|
||||
|
||||
if (kettoHatvanyok.Contains(ertek))
|
||||
{
|
||||
int index = 0;
|
||||
while (kettoHatvanyok[index] != ertek)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
|
||||
KettoHatvanyokTagokHozzaAdasa(index);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ertek == 1) {
|
||||
Tagok.Add(ertek);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ertek % 2 == 0)
|
||||
{
|
||||
ujertek = ertek / 2;
|
||||
|
||||
} else
|
||||
{
|
||||
ujertek = ertek * 3 + 1;
|
||||
}
|
||||
|
||||
Tagok.Add(ertek);
|
||||
return TagokKiszamitasa(ujertek);
|
||||
}
|
||||
|
||||
public void KettoHatvanyokTagokHozzaAdasa(int index)
|
||||
{
|
||||
for (int i = index; i >= 0; i--)
|
||||
{
|
||||
Tagok.Add(kettoHatvanyok[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public Sorozat(Sorozat sorozat)
|
||||
{
|
||||
KezdoErtek = sorozat.KezdoErtek;
|
||||
Tagok = sorozat.Tagok;
|
||||
}
|
||||
|
||||
public Sorozat(int kezdoErtek)
|
||||
{
|
||||
this.KezdoErtek = kezdoErtek;
|
||||
}
|
||||
}
|
||||
}
|
BIN
fordulo_3/Program/bin/Debug/Program.exe
Normal file
BIN
fordulo_3/Program/bin/Debug/Program.exe
Normal file
Binary file not shown.
6
fordulo_3/Program/bin/Debug/Program.exe.config
Normal file
6
fordulo_3/Program/bin/Debug/Program.exe.config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
BIN
fordulo_3/Program/bin/Debug/Program.pdb
Normal file
BIN
fordulo_3/Program/bin/Debug/Program.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.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
52261ac204714890afe2467c25b9765789d39c141c743f2c478f13be997c8941
|
|
@ -0,0 +1,7 @@
|
|||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\bin\Debug\Program.exe.config
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\bin\Debug\Program.exe
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\bin\Debug\Program.pdb
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.csproj.AssemblyReference.cache
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.csproj.CoreCompileInputs.cache
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.exe
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.pdb
|
BIN
fordulo_3/Program/obj/Debug/Program.exe
Normal file
BIN
fordulo_3/Program/obj/Debug/Program.exe
Normal file
Binary file not shown.
BIN
fordulo_3/Program/obj/Debug/Program.pdb
Normal file
BIN
fordulo_3/Program/obj/Debug/Program.pdb
Normal file
Binary file not shown.
|
@ -30,7 +30,7 @@
|
|||
- b: `alfa`
|
||||
- c: `6`
|
||||
- d: `4`
|
||||
- e: `98`
|
||||
- e: `102`
|
||||
|
||||
### 3. feladat
|
||||
- a: `213`
|
||||
|
|
Loading…
Reference in New Issue
Block a user