Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- namespace ConsoleApp2
- {
- class Program
- {
- static List<Egyszam> egyszamLista = new List<Egyszam>();
- static void Main(string[] args)
- {
- StreamReader sr = new StreamReader("egyszamjatek1.txt");
- string sor = "";
- while (!sr.EndOfStream)
- {
- sor = sr.ReadLine();
- Egyszam e = new Egyszam(sor); //egyed
- egyszamLista.Add(e);
- }
- sr.Close();
- Console.WriteLine("3. feladat:");
- Console.Write("Játékosok száma:{0}",egyszamLista.Count);
- Console.WriteLine("4.feladat:");
- Console.Write("Kérem a forduló sorszmát: ");
- int sorszám = int.Parse(Console.ReadLine());
- Console.WriteLine("5. feladat:");
- int ossz = 0;
- for (int i = 0; i < egyszamLista.Count; i++)
- {
- ossz = ossz + egyszamLista[i].Fordulok[sorszám - 1];
- }
- double atlag = (double)ossz / egyszamLista.Count;
- Console.WriteLine("A mgadott forduló tippjeinek átlaga: {0}", atlag.ToString("F2") );
- }
- }
- }
- ---------------------------------------------------------------------------------------------------
- Egyszam Class
- ---------------------------------------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApp2
- {
- class Egyszam
- {
- string nev;
- List<int> fordulok = new List<int>();
- public Egyszam(string sor)
- {
- string[] d = sor.Split(" ");
- nev = d[0];
- for (int i = 1; i < d.Length; i++)
- {
- fordulok.Add(int.Parse(d[i]));
- }
- }
- public string Nev { get => nev; set => nev = value; }
- public List<int> Fordulok { get => fordulok; set => fordulok = value; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement