Advertisement
Guest User

Untitled

a guest
Feb 6th, 2018
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace _06.Hospital
  6. {
  7. class Hospital
  8. {
  9. static void Main(string[] args)
  10. {
  11. var departments = new Dictionary<string, List<string>>();
  12. var doctors = new Dictionary<string, List<string>>();
  13. var line = Console.ReadLine();
  14.  
  15. while (line != "Output")
  16. {
  17. var tokens = line.Split().ToArray();
  18. var dep = tokens[0];
  19. var dfn= tokens[1]+" "+ tokens[2];
  20. var patient = tokens[3];
  21. if (!departments.ContainsKey(dep))
  22. {
  23. departments[dep] = new List<string>();
  24. }
  25. departments[dep].Add(patient);
  26. if (!doctors.ContainsKey(dfn))
  27. {
  28. doctors[dfn] = new List<string>();
  29. }
  30. doctors[dfn].Add(patient);
  31. line = Console.ReadLine();
  32. }
  33. line = Console.ReadLine().Trim();
  34. while (line != "End")
  35. {
  36. var token = line.Split().ToArray();
  37. if (token.Length == 1)
  38. {
  39. foreach (var patients in departments[line])
  40. {
  41. Console.WriteLine(patients);
  42. }
  43. }
  44. else if (int.TryParse(token[1], out int result))
  45. {
  46. if (int.Parse(token[1]) > 20)
  47. {
  48. continue;
  49. }
  50. var patients = departments[token[0]];
  51. var room = patients.Skip( 3 * (int.Parse(token[1])-1)).ToList();
  52. room.Sort();
  53.  
  54. foreach (var patient in room)
  55. {
  56. Console.WriteLine(patient);
  57. }
  58. }
  59. else
  60. {
  61. var pat = doctors[line];
  62. pat.Sort();
  63. foreach (var patient in pat)
  64. {
  65. Console.WriteLine(patient);
  66.  
  67. }
  68. }
  69. line = Console.ReadLine();
  70. }
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement