//feladatszám: I. 489. //név: Nagy 793 Márton, 12. osztály //iskola: Vác, Boronkay György Műszaki Szakközépiskola, Gimnázium és Kollégium //program: Visual Studio Enterprise 2015, Version 14.0.25431.01 Update 3 using System; using System.Collections.Generic; using System.Linq; using System.IO; namespace i489 { struct Foto { public string hely; public string datum; public List emberek; } class Program { static StreamReader be = new StreamReader("kepszem.txt"); static int k; static Foto[] fotok; static string[] csalad = { "Anya", "Apa", "Hugi", "Mama", "Ocsi", "Papa" }; static List szemelyek = new List(); static void Beolvas() { k = int.Parse(be.ReadLine()); fotok = new Foto[k]; for (int i = 0; i < k; i++) { string[] split = be.ReadLine().Split(' '); fotok[i].hely = split[0]; fotok[i].datum = split[1]; fotok[i].emberek = new List(); for (int j = 2; j < split.Length; j++) { fotok[i].emberek.Add(split[j]); if (!szemelyek.Contains(split[j])) szemelyek.Add(split[j]); //4. feladat előkészítése } } be.Close(); } static void F1() { Console.WriteLine("1. feladat:"); int count = szemelyek.Count(); for (int i = 0; i < csalad.Length; i++) if (szemelyek.Contains(csalad[i])) count--; //csaladtagok levonasa if (szemelyek.Contains("En")) count--; //onmaga levonasa Console.WriteLine("Tamasnak " + count + " ismerose szerepel a kepeken."); } static void F2() { int count = 0; for (int i = 0; i < k; i++) if (fotok[i].hely == "-" && fotok[i].datum == "-") count++; //feltételes megszámlálás Console.WriteLine("2. feladat:"); Console.WriteLine(count + " kep keszitesenek ideje es helye ismeretlen."); } static void F3() { int max = 0; for (int i = 0; i < k; i++) if (fotok[i].emberek.Count > max) max = fotok[i].emberek.Count; //maximumkeresés Console.WriteLine("3. feladat:"); Console.WriteLine(max + " embernel nincs tobb egy kepen sem."); } static void F4() { szemelyek.Sort(); Console.WriteLine("4. feladat:"); Console.Write("A kepeken szerepel:"); for (int i = 0; i < szemelyek.Count - 1; i++) { Console.Write(" " + szemelyek[i] + ","); } Console.WriteLine(" " + szemelyek[szemelyek.Count - 1] + "."); } static void F5() { Console.WriteLine("5. feladat:"); Console.Write("Kerem adj meg egy szereplot: "); string szereplo = Console.ReadLine(); List datumok = new List(); for (int i = 0; i < k; i++) { if (fotok[i].datum != "-") { if (fotok[i].emberek.Contains(szereplo) && fotok[i].emberek.Contains("En") && !datumok.Contains(fotok[i].datum)) //mindketten rajta vannak és azonos dátum ne szerepeljen kétszer { datumok.Add(fotok[i].datum); } } } if (datumok.Count == 0) Console.WriteLine("Tamas es " + szereplo + " nem szerepel kozosen ismert idopontban keszitett kepen."); else { Console.Write("Tamas es " + szereplo + " kozos idopontjai:"); for (int i = 0; i < datumok.Count; i++) Console.Write(" " + datumok[i]); Console.WriteLine(); } } static void F6() { Console.WriteLine("6. feladat:"); Console.WriteLine("Csaladi tablo"); for (int i = 0; i < k; i++) { List csaladtagok = new List(); for (int j = 0; j < 6; j++) if (fotok[i].emberek.Contains(csalad[j])) csaladtagok.Add(csalad[j]); //képen szereplő családtagok kigyűjtése if (csaladtagok.Count >= 2) { if (fotok[i].emberek.Contains("En")) csaladtagok.Add("En"); csaladtagok.Sort(); Console.Write(fotok[i].hely); for (int j = 0; j < 16 - fotok[i].hely.Length; j++) Console.Write(" "); //tabulálás Console.Write(fotok[i].datum); for (int j = 0; j < 16 - fotok[i].datum.Length; j++) Console.Write(" "); //tabulálás for (int j = 0; j < csaladtagok.Count - 1; j++) Console.Write(csaladtagok[j] + " "); Console.WriteLine(csaladtagok[csaladtagok.Count - 1]); } } } static void Main(string[] args) { Beolvas(); F1(); F2(); F3(); F4(); F5(); F6(); } } }