Advertisement
Guest User

JediMeditation

a guest
Jun 15th, 2016
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ExamPreparation
  8. {
  9. class JediMeditation
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. var master = new List<string>();
  15. var knight = new List<string>();
  16. var padawan = new List<string>();
  17. var toshkoSlav = new List<string>();
  18. var yoda = new List<string>();
  19.  
  20. for (int i = 0; i < n; i++)
  21. {
  22. string[] input = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
  23.  
  24. for (int j = 0; j < input.Length ; j++)
  25. {
  26. var currentJedi = input[j].ToLower();
  27.  
  28. if (currentJedi.StartsWith("m"))
  29. {
  30. master.Add(currentJedi);
  31. }
  32. if (currentJedi.StartsWith("k"))
  33. {
  34. knight.Add(currentJedi);
  35. }
  36. if (currentJedi.StartsWith("p"))
  37. {
  38. padawan.Add(currentJedi);
  39. }
  40. if (currentJedi.StartsWith("t"))
  41. {
  42. toshkoSlav.Add(currentJedi);
  43. }
  44. if (currentJedi.StartsWith("s"))
  45. {
  46. toshkoSlav.Add(currentJedi);
  47. }
  48. if (currentJedi.StartsWith("y"))
  49. {
  50. yoda.Add(currentJedi);
  51. }
  52.  
  53. }
  54.  
  55. }
  56.  
  57. if (!yoda.Any())
  58. {
  59. Console.WriteLine(string.Join(" ",toshkoSlav) + " " + string.Join(" ",master) + " " + string.Join(" ",knight) +
  60. " " + string.Join(" ",padawan));
  61. }
  62. else
  63. {
  64. Console.WriteLine(string.Join(" ", master) + " " + string.Join(" ", knight) + " " + string.Join(" ", toshkoSlav) + " " +
  65. string.Join(" ", padawan));
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement