fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Hello{
  5. private static readonly Dictionary<string, int> HAND_CODE_DICT = new Dictionary<string, int>() {
  6. {"グー", 0},
  7. {"チョキ", 1},
  8. {"パー", 2},
  9. };
  10. private static readonly string[] HAND_LABELS = new string[] {"✊", "✌", "🖐"};
  11. private static readonly string[] RESULT_LABELS = new string[] {
  12. "あいこ",
  13. "あなたの負け",
  14. "あなたの勝ち"
  15. };
  16.  
  17. private static int GetResult(int palyer_hand, int pc_hand) {
  18. int result = palyer_hand - pc_hand;
  19. // -3 < n < 3
  20. result %= 3;
  21. // 0 < n < 6
  22. result += 3;
  23. // 0 <= n < 3
  24. result %= 3;
  25. return result;
  26. }
  27.  
  28. public static void Main(){
  29. // Your code here!
  30. System.Console.WriteLine("Hellow C#");
  31.  
  32. foreach(string player_hand in new string[]{"グー", "チョキ", "パー"}) {
  33. foreach(string pc_hand in new string[]{"グー", "チョキ", "パー"}) {
  34. int player_hand_code = HAND_CODE_DICT[player_hand];
  35. int pc_hand_code = HAND_CODE_DICT[pc_hand];
  36. int result_code = GetResult(player_hand_code, pc_hand_code);
  37. System.Console.WriteLine(string.Format("[{0} v.s. {1}] {2}", new object[] {
  38. HAND_LABELS[player_hand_code],
  39. HAND_LABELS[pc_hand_code],
  40. RESULT_LABELS[result_code],
  41. }));
  42. }
  43. }
  44. }
  45. }
  46.  
Success #stdin #stdout 0.02s 16312KB
stdin
Standard input is empty
stdout
Hellow C#
[✊ v.s. ✊] あいこ
[✊ v.s. ✌] あなたの勝ち
[✊ v.s. 🖐] あなたの負け
[✌ v.s. ✊] あなたの負け
[✌ v.s. ✌] あいこ
[✌ v.s. 🖐] あなたの勝ち
[🖐 v.s. ✊] あなたの勝ち
[🖐 v.s. ✌] あなたの負け
[🖐 v.s. 🖐] あいこ