Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 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 _05.HandsOfCards
  8. {
  9. class Program
  10. {
  11. static int sum(List<string>a)
  12. {
  13. int n = 0;
  14. for(int i=0;i<a.Count();i++)
  15. {
  16. int s = 0;
  17.  
  18. switch(a[i][0])
  19. {
  20. case '2':s = 2;break;
  21. case '3': s = 3; break;
  22. case '4': s = 4; break;
  23. case '5': s = 5; break;
  24. case '6': s = 6; break;
  25. case '7': s = 7; break;
  26. case '8': s = 8; break;
  27. case '9': s = 9; break;
  28. case '1': s = 10; break;
  29. case 'J': s = 11; break;
  30. case 'Q': s = 12; break;
  31. case 'K': s = 13; break;
  32. case 'A': s = 14; break;
  33.  
  34. }
  35. int t = 1;
  36. if (a[i][0] == '1') t++;
  37.  
  38. switch(a[i][t])
  39. {
  40. case 'S':s = s * 4;break;
  41. case 'H': s = s * 3; break;
  42. case 'D': s = s * 2; break;
  43. case 'C': s = s * 1; break;
  44. }
  45.  
  46. n = n + s;
  47. }
  48. return n;
  49. }
  50. static void Main(string[] args)
  51. {
  52. var a = Console.ReadLine().Trim().Split(new char[] { ':', ' ', ',' }).ToArray();
  53. //Console.WriteLine(string.Join(",", a));
  54. var cards = new Dictionary<string, List<string> > ();
  55. while(a[0]!="JOKER")
  56. {
  57. // Console.WriteLine(a[0]);
  58. for(int i=1;i<a.Length;i++)
  59. {
  60. if(a[i]!="")
  61. {
  62. // Console.WriteLine(a[i]);
  63. if (cards.ContainsKey(a[0])) { if (!cards[a[0]].Contains(a[i])) cards[a[0]].Add(a[i]); }
  64. else cards.Add(a[0], new List<string> { a[i] });
  65. }
  66.  
  67. }
  68. a = Console.ReadLine().Trim().Split(new char[] { ':', ' ', ',' }).ToArray();
  69. }
  70. foreach(var n in cards)
  71. {
  72.  
  73. Console.WriteLine($"{n.Key}: {sum(n.Value)}");
  74. //Console.WriteLine(string.Join(",", n.Value));
  75.  
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement