コード例 #1
0
    public static void Main()
    {
        var peopleCount = int.Parse(Console.ReadLine());
        var family      = new Family();

        for (var i = 0; i < peopleCount; i++)
        {
            var args   = Console.ReadLine().Split();
            var person = new Person(int.Parse(args[1]), args[0]);

            family.AddMembers(person);
        }

        Console.WriteLine(family.GetOldestMember().ToString());
    }
コード例 #2
0
    static void Main()
    {
        int    n      = int.Parse(Console.ReadLine());
        Family family = new Family();

        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine().Split();
            string   name  = input[0];
            int      age   = int.Parse(input[1]);

            Person newPerson = new Person(name, age);
            family.AddMembers(newPerson);
        }
        Console.WriteLine($"{family.GetOldestMember().Name} {family.GetOldestMember().Age}");
    }
コード例 #3
0
    static void OldestFamilyMember()
    {
        int    n      = int.Parse(Console.ReadLine());
        Family family = new Family();

        for (int a = 0; a < n; a++)
        {
            string[] input = Console.ReadLine().Split();
            string   name  = input[0];
            int      age   = int.Parse(input[1]);

            Person person = new Person(name, age);
            family.AddMembers(person);
        }

        Console.WriteLine(family.GetOldestMember());
    }