Advertisement
terlichki

Untitled

Jun 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 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 Problem_2___Snowmen
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<int> input = Console.ReadLine()
  14. .Split(' ')
  15. .Select(int.Parse)
  16. .ToList();
  17.  
  18. List<int> bleackList = new List<int>();
  19. int attackerPower = 0;
  20. while (input.Count>1) {
  21. for (int index = 0; index < input.Count; index++)
  22. {
  23. int attacker = index;
  24. attackerPower = input[index];
  25. int target = input[index];
  26. // int looser = -1;
  27. int beetResult = 0;
  28.  
  29.  
  30. if (target < input.Count)
  31. {
  32. beetResult = Math.Abs(attacker - target);
  33. }
  34. else
  35. {
  36. beetResult = target % input.Count;
  37. }
  38. if (target == attacker)
  39. {
  40. Console.WriteLine($"{attacker} performed harakiri");
  41. bleackList.Add(attacker);
  42. bleackList.Distinct();
  43.  
  44. }
  45. if (beetResult % 2 == 0 && beetResult != 0)
  46. {
  47. // winer = attacker;
  48. Console.WriteLine($"{attacker} x {target} -> {attacker} wins");
  49. bleackList.Add(target);
  50. bleackList.Distinct();
  51.  
  52. }
  53. if (beetResult % 2 != 0)
  54. {
  55. Console.WriteLine($"{attacker} x {target} -> {target} wins");
  56. bleackList.Add(attacker);
  57. bleackList.Distinct();
  58. }
  59.  
  60. }
  61. foreach (var losers in bleackList)
  62. {
  63. input.RemoveAt(losers);
  64. }
  65. bleackList.Clear();
  66.  
  67. }
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement