Advertisement
Guest User

hospital

a guest
Jun 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _4.Hospital
  6. {
  7. class Hospital
  8. {
  9. static void Main()
  10. {
  11. var res = new List<Person>();
  12. string line;
  13. while ((line = Console.ReadLine())!="Output")
  14. {
  15. string[] info = line.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
  16. string departName = info[0];
  17. string doctor = info[1]+info[2];
  18. string personName = info[3];
  19. Person p = new Person();
  20. p.Name = personName;
  21. p.Doctor = doctor;
  22. p.Department = departName;
  23. res.Add(p);
  24. }
  25. line = string.Empty;
  26. while ((line = Console.ReadLine()) != "End")
  27. {
  28. string[] param = line.Split(' ');
  29.  
  30.  
  31. if (param.Length==1)
  32. {
  33. foreach (var item in res.Where(x=>x.Department == param[0]))
  34. {
  35. Console.WriteLine(item.Name);
  36. }
  37. continue;
  38. }
  39. int count;
  40. if (int.TryParse(param[1],out count))
  41. {
  42. foreach (var item in res.Where(x=>x.Department == param[0]).Skip((count-1)*3).Take(3).ToList().OrderBy(x=>x.Name))
  43. {
  44. Console.WriteLine(item.Name);
  45. }
  46. continue;
  47. }
  48. else
  49. {
  50. foreach (var item in res.Where(x => x.Doctor == param[0]+param[1]).OrderBy(x=>x.Name))
  51. {
  52. Console.WriteLine(item.Name);
  53. }
  54. }
  55. }
  56. }
  57. }
  58. class Person
  59. {
  60. public string Name { get; set; }
  61. public string Doctor { get; set; }
  62. public string Department { get; set; }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement