Finished gyakorlas (NO GUI)

This commit is contained in:
Digi
2024-09-07 11:30:29 +02:00
parent 011436e3de
commit 1ac18d6715
34 changed files with 647 additions and 20 deletions

Binary file not shown.

View 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>

View 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>{A3C42417-ACFF-40C0-9195-7287F201E9F6}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp1</RootNamespace>
<AssemblyName>ConsoleApp1</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" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34408.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1.csproj", "{A3C42417-ACFF-40C0-9195-7287F201E9F6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A3C42417-ACFF-40C0-9195-7287F201E9F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3C42417-ACFF-40C0-9195-7287F201E9F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3C42417-ACFF-40C0-9195-7287F201E9F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3C42417-ACFF-40C0-9195-7287F201E9F6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {130F6D27-01E8-4FAB-B8E4-4EC359F9BB1B}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Security.Permissions;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
DataRead();
int num = Feladat3();
Console.WriteLine(num);
int nepsuruseg = Feladat4();
Console.WriteLine(nepsuruseg);
int kinatobbmintindiaaaaa = Feladat5();
Console.WriteLine(kinatobbmintindiaaaaa);
string harmadik = Feladat6();
Console.WriteLine(harmadik);
Feladat7();
Console.ReadLine();
}
public static void DataRead()
{
string path = "adatok-utf8.txt";
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader streamReader = new StreamReader(fileStream);
string line = streamReader.ReadLine();
line = streamReader.ReadLine();
while (line != null)
{
string[] datas = line.Split(';');
string orszagnev = datas[0];
int terulet = Convert.ToInt32(datas[1]);
string nepesseg = datas[2];
int Nepesseg;
bool IsNumber = Int32.TryParse(nepesseg, out Nepesseg);
if (!IsNumber)
{
string asd = nepesseg.Replace("g", "0000");
Nepesseg = Convert.ToInt32(asd);
}
int fovarosNepesseg = Convert.ToInt32(datas[4]);
Orszag orszag = new Orszag(orszagnev, terulet, Nepesseg, datas[3], fovarosNepesseg);
Data.orszagok.Add(orszag);
line = streamReader.ReadLine();
}
streamReader.Close();
fileStream.Close();
}
public static int Feladat3()
{
return Data.orszagok.Count;
}
public static int FindCountry(string country) {
int i = 0;
while (Data.orszagok[i].Orszagnev != country && i <= Data.orszagok.Count)
{
i++;
}
return i;
}
public static int Feladat4() {
int a = FindCountry("Kína");
return Data.orszagok[a].Nepesseg / Data.orszagok[a].Terulet;
}
public static int Feladat5() {
int india = FindCountry("India");
int kina = FindCountry("Kína");
return Data.orszagok[kina].Nepesseg - Data.orszagok[india].Nepesseg;
}
public static string Feladat6()
{
List<Orszag> asd = Data.orszagok.OrderBy(x => x.Nepesseg).ToList();
return asd[asd.Count - 3].Orszagnev;
}
public static void Feladat7()
{
foreach (var item in Data.orszagok)
{
if (item.FovarosiKoncentracio)
{
Console.WriteLine($"{item.Orszagnev}, {item.Fovaros}");
}
}
}
}
public static class Data
{
public static List<Orszag> orszagok = new List<Orszag>();
}
public class Orszag
{
public string Orszagnev { get; private set; }
public int Terulet { get; private set; }
public int Nepesseg { get; private set; }
public string Fovaros { get; private set; }
public int FovarosNepesseg { get; private set; }
public bool FovarosiKoncentracio { get; private set; }
public Orszag(string orszagnev, int terulet, int nepesseg, string fovaros, int fovarosNepesseg)
{
Orszagnev = orszagnev;
Terulet = terulet;
Nepesseg = nepesseg;
Fovaros = fovaros;
FovarosNepesseg = fovarosNepesseg * 1000;
FovarosiKoncentracio = KoncentraltFovaros(FovarosNepesseg, Nepesseg);
}
public bool KoncentraltFovaros(int fovarosNepesseg, int nepesseg)
{
if (fovarosNepesseg >= nepesseg * 0.3)
{
return true;
}
else
{
return false;
}
}
}
}

View File

@@ -0,0 +1,36 @@
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("a3c42417-acff-40c0-9195-7287f201e9f6")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Binary file not shown.

View 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>

Binary file not shown.

View File

@@ -0,0 +1,50 @@
Ország;Terület;Népesség;Főváros;Főváros népessége
Görögország;132000;1064g;Athén;3154
Románia;238400;1912g;Bukarest;1812
Ausztria;83900;8960000;Bécs;1915
Lengyelország;312700;3775g;Varsó;1776
Belgium;30500;11590000;Brüsszel;2065
Bulgária;110400;6880000;Szófia;1277
Ciprus;9300;900000;Nicosia;270
Csehország;78900;10510000;Prága;1299
Dánia;42900;5860000;Koppenhága;1334
Észtország;45400;1330000;Tallinn;441
Finnország;336900;5540000;Helsinki;1292
Franciaország;551500;67750000;Párizs;10958
Hollandia;41500;17530000;Amszterdam;1140
Horvátország;56600;3960000;Zágráb;685
Írország;69800;5030000;Dublin;1215
Lettország;64600;1880000;Riga;634
Litvánia;65300;2800000;Vilnius;538
Luxemburg;2600;640000;Luxembourg;120
Magyarország;93000;9710000;Budapest;1764
Málta;300;520000;Valletta;213
Németország;357600;83200000;Berlin;3557
Olaszország;302100;59110000;Róma;4234
Portugália;92200;10330000;Lisszabon;2942
Spanyolország;506000;47420000;Madrid;6559
Svédország;438600;10420000;Stockholm;1608
Szlovákia;49000;5450000;Pozsony;433
Szlovénia;20300;2110000;Ljubljana;287
Egyesült Királyság;244400;67330000;London;9177
Izland;103000;370000;Reykjavík;216
Észak-Macedónia;25700;1950000;Szkopje;590
Montenegró;13900;620000;Podgorica;177
Norvégia;323800;5410000;Osló;1027
Oroszország;17098200;143450000;Moszkva;12476
Svájc;41300;8700000;Bern;426
Szerbia;88400;6830000;Belgrád;1394
Törökország;783600;84150000;Ankara;5018
India;3287300;1393410000;Új-Delhi;29399
Izrael;22100;9360000;Jeruzsálem;919
Japán;377900;125680000;Tokió;37435
Kína;9600000;1412360000;Peking;20036
Koreai Köztársaság;100400;51740000;Szöul;9962
Dél-afrikai Köztársaság;1221000;60040000;Pretoriap;2473
Egyiptom;1002000;104260000;Kairó;20485
Brazília;8510300;213990000;Brasilia;4559
Egyesült Államok;9833500;331890000;Washington, D.C.;5265
Kanada;9984700;38250000;Ottawa;1378
Mexikó;1964400;130260000;Mexikóváros;21672
Ausztrália;7692000;25740000;Canberra;453
Új-Zéland;268100;5120000;Wellington;413

View File

@@ -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")]

View File

@@ -0,0 +1 @@
25f359d3fd7d560a1dec87ab383b84f91627954af157e6d29c6e8f4a1e97b265

View File

@@ -0,0 +1,7 @@
E:\Házi\Programozás\C#\Suli\ProgaOra\20240904\ConsoleApp1\bin\Debug\ConsoleApp1.exe.config
E:\Házi\Programozás\C#\Suli\ProgaOra\20240904\ConsoleApp1\bin\Debug\ConsoleApp1.exe
E:\Házi\Programozás\C#\Suli\ProgaOra\20240904\ConsoleApp1\bin\Debug\ConsoleApp1.pdb
E:\Házi\Programozás\C#\Suli\ProgaOra\20240904\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.AssemblyReference.cache
E:\Házi\Programozás\C#\Suli\ProgaOra\20240904\ConsoleApp1\obj\Debug\ConsoleApp1.csproj.CoreCompileInputs.cache
E:\Házi\Programozás\C#\Suli\ProgaOra\20240904\ConsoleApp1\obj\Debug\ConsoleApp1.exe
E:\Házi\Programozás\C#\Suli\ProgaOra\20240904\ConsoleApp1\obj\Debug\ConsoleApp1.pdb

Binary file not shown.

Binary file not shown.