ProgaOra/20240117/ConsoleApp1/Program.cs

90 lines
2.4 KiB
C#
Raw Normal View History

2024-01-17 11:10:02 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApp1
{
public class Adat
{
public int helyezes;
public int sportolok_szama;
public string sportag;
public string versenyszam;
public Adat(int hely, int szam, string sport, string vszam)
{
helyezes = hely;
sportolok_szama = szam;
sportag = sport;
versenyszam = vszam;
}
}
class Program
{
static void Feladat()
{
FileStream fs = new FileStream("helsinki.txt", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
List<Adat> adatok = new List<Adat>();
string sor = sr.ReadLine();
while (sor != null)
{
string[] xd = sor.Split(' ');
Adat asd = new Adat(Convert.ToInt32(xd[0]), Convert.ToInt32(xd[1]), xd[2], xd[3]);
adatok.Add(asd);
sor = sr.ReadLine();
}
sr.Close();
fs.Close();
int pontszerzok = 0;
int arany = 0;
int ezust = 0;
int bronz = 0;
foreach (var item in adatok)
{
switch (item.helyezes){
case 1:
arany++;
goto pont;
case 2:
ezust++;
goto pont;
case 3:
bronz++;
goto pont;
case 4:
arany++;
goto pont;
pont:
pontszerzok++;
break;
default:
break;
}
if (item.helyezes <= 6)
{
pontszerzok++;
}
}
Console.WriteLine("3.feladat:");
Console.WriteLine($"Pontszerző helyezések száma: {pontszerzok}");
Console.WriteLine("4.feladat:");
Console.WriteLine($"Pontszerző helyezések száma: {pontszerzok}");
}
static void Main(string[] args)
{
Feladat();
}
}
}