Added footgolf homework
This commit is contained in:
153
20240123/hazi.txt
Normal file
153
20240123/hazi.txt
Normal file
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace footgolf
|
||||
{
|
||||
class fobDatabase
|
||||
{
|
||||
public string versenyzoNeve { get; set;}
|
||||
public string versenyzoKategoriaja { get; set; }
|
||||
public string versenyzoEgyesuletNeve { get; set; }
|
||||
public int[] versenyzoPontjai = { };
|
||||
|
||||
public fobDatabase(string line)
|
||||
{
|
||||
string[] splittedLine = line.Split(';');
|
||||
this.versenyzoNeve = splittedLine[0];
|
||||
this.versenyzoKategoriaja = splittedLine[1];
|
||||
this.versenyzoEgyesuletNeve = splittedLine[2];
|
||||
for (int i = 3; i < splittedLine.Length; i++)
|
||||
{
|
||||
versenyzoPontjai = versenyzoPontjai.Append(int.Parse(splittedLine[i])).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public int [] valogatottLista = { };
|
||||
public int pontSumma = 0;
|
||||
|
||||
public void pontSzamitas(int [] lista)
|
||||
{
|
||||
Array.Sort(lista);
|
||||
for (int i = 0; i < lista.Length; i++)
|
||||
{
|
||||
if (lista[0] != 0)
|
||||
{
|
||||
Console.WriteLine(pontSumma);
|
||||
pontSumma += 10;
|
||||
Console.WriteLine(pontSumma);
|
||||
}
|
||||
else if(lista[1] != 0)
|
||||
{
|
||||
Console.WriteLine(pontSumma);
|
||||
pontSumma += 10;
|
||||
Console.WriteLine(pontSumma);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 2; i < lista.Length; i++)
|
||||
{
|
||||
valogatottLista = valogatottLista.Append(lista[i]).ToArray();
|
||||
}
|
||||
|
||||
for (int i = 0; i < valogatottLista.Length; i++)
|
||||
{
|
||||
pontSumma += valogatottLista[i];
|
||||
}
|
||||
/*for (int i = 0; i < valogatottLista.Length; i++)
|
||||
{
|
||||
Console.Write($"{valogatottLista[i]}, ");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace footgolf
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//2. feladat
|
||||
|
||||
string[] sorok = File.ReadAllLines("C:\\Users\\medvegergo\\Desktop\\fob2016.txt");
|
||||
List<fobDatabase> db = new List<fobDatabase>();
|
||||
|
||||
for (int i = 0; i < sorok.Length; i++)
|
||||
{
|
||||
fobDatabase bemenet = new fobDatabase(sorok[i]);
|
||||
db.Add(bemenet);
|
||||
}
|
||||
|
||||
//3. feladat
|
||||
Console.WriteLine($"3. feladat: Versenyzők száma: {db.Count}");
|
||||
|
||||
//4. feladat
|
||||
double nokSzama = 0;
|
||||
for (int i = 0; i < db.Count; i++)
|
||||
{
|
||||
if (db[i].versenyzoKategoriaja == "Noi")
|
||||
{
|
||||
nokSzama++;
|
||||
}
|
||||
}
|
||||
Console.WriteLine($"4. feladat: A női versenyzők aránya: {Math.Round((nokSzama / db.Count) * 100, 2)}");
|
||||
|
||||
//5. feladat
|
||||
for (int i = 0; i < db.Count; i++)
|
||||
{
|
||||
int[] bemenetiLista = db[i].versenyzoPontjai;
|
||||
db[i].pontSzamitas(bemenetiLista);
|
||||
}
|
||||
|
||||
//6. feladat
|
||||
Console.WriteLine("6. feladat: A bajnok női versenyző");
|
||||
int index = 0;
|
||||
int legnagyobbPont = 0;
|
||||
for (int i = 0; i < db.Count; i++)
|
||||
{
|
||||
if (db[i].pontSumma > legnagyobbPont)
|
||||
{
|
||||
legnagyobbPont = db[i].pontSumma;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
Console.WriteLine($"Név: {db[index].versenyzoNeve}");
|
||||
Console.WriteLine($"Egyesület: {db[index].versenyzoEgyesuletNeve}");
|
||||
Console.WriteLine($"Összpont: {db[index].pontSumma}");
|
||||
|
||||
|
||||
//7. feladat
|
||||
|
||||
string[] irandoSorok = { };
|
||||
for (int i = 0; i < db.Count; i++)
|
||||
{
|
||||
if(db[i].versenyzoKategoriaja == "Felnott ferfi")
|
||||
{
|
||||
string irandoSor = $"{db[i].versenyzoNeve};{db[i].pontSumma}";
|
||||
irandoSorok = irandoSorok.Append(irandoSor).ToArray();
|
||||
}
|
||||
}
|
||||
File.WriteAllLines("C:\\Users\\medvegergo\\Desktop\\osszpontFF.txt", irandoSorok);
|
||||
Console.WriteLine();
|
||||
|
||||
/*for (int i = 0; i < db.Count; i++)
|
||||
{
|
||||
Console.WriteLine(db[i].versenyzoNeve);
|
||||
}*/
|
||||
|
||||
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user