Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _4.Hospital
- {
- class Hospital
- {
- static void Main()
- {
- var res = new List<Person>();
- string line;
- while ((line = Console.ReadLine())!="Output")
- {
- string[] info = line.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
- string departName = info[0];
- string doctor = info[1]+info[2];
- string personName = info[3];
- Person p = new Person();
- p.Name = personName;
- p.Doctor = doctor;
- p.Department = departName;
- res.Add(p);
- }
- line = string.Empty;
- while ((line = Console.ReadLine()) != "End")
- {
- string[] param = line.Split(' ');
- if (param.Length==1)
- {
- foreach (var item in res.Where(x=>x.Department == param[0]))
- {
- Console.WriteLine(item.Name);
- }
- continue;
- }
- int count;
- if (int.TryParse(param[1],out count))
- {
- foreach (var item in res.Where(x=>x.Department == param[0]).Skip((count-1)*3).Take(3).ToList().OrderBy(x=>x.Name))
- {
- Console.WriteLine(item.Name);
- }
- continue;
- }
- else
- {
- foreach (var item in res.Where(x => x.Doctor == param[0]+param[1]).OrderBy(x=>x.Name))
- {
- Console.WriteLine(item.Name);
- }
- }
- }
- }
- }
- class Person
- {
- public string Name { get; set; }
- public string Doctor { get; set; }
- public string Department { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement