예제 #1
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Family family = new Family();

            for (int i = 0; i < n; i++)
            {
                string[] personArgs = Console.ReadLine()
                                      .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                                      .ToArray();

                string name = personArgs[0];

                int age = int.Parse(personArgs[1]);

                Person person = new Person(age, name);

                family.AddMember(person);
            }

            HashSet <Person> result = family.GetAllPeopleAbove30();

            Console.WriteLine(String.Join(Environment.NewLine, result));
        }
예제 #2
0
        public static void Main()
        {
            Family family = new Family();

            int membersCount = int.Parse(Console.ReadLine());

            try
            {
                for (int i = 0; i < membersCount; i++)
                {
                    string[] personArgs = Console.ReadLine()
                                          .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                          .ToArray();

                    string name = personArgs[0];
                    int    age  = int.Parse(personArgs[1]);

                    Person person = new Person(name, age);

                    family.AddMember(person);
                }

                HashSet <Person> result = family.GetAllPeopleAbove30();
                Console.WriteLine(string.Join(Environment.NewLine, result));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            Family family = new Family();
            int    n      = int.Parse(Console.ReadLine());

            while (n-- > 0)
            {
                string[] personData = Console.ReadLine().Split();
                string   name       = personData[0];
                int      age        = int.Parse(personData[1]);
                family.AddMember(new Person(name, age));
            }

            HashSet <Person> result = family.GetAllPeopleAbove30();

            Console.WriteLine(string.Join(Environment.NewLine, result));
        }
예제 #4
0
        static void Main(string[] args)
        {
            Family family = new Family();
            int    n      = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] personArgs = Console.ReadLine().Split();
                string   name       = personArgs[0];
                int      age        = int.Parse(personArgs[1]);
                Person   person     = new Person(name, age);
                family.AddMember(person);
            }
            HashSet <Person> result = family.GetAllPeopleAbove30();

            Console.WriteLine(string.Join(Environment.NewLine, result));
        }