Advertisement
elninio_79

Untitled

Mar 19th, 2019
76
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 gameNumberWars
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string firstname = Console.ReadLine();
  14. string secondname = Console.ReadLine();
  15.  
  16. int counterone = 0;
  17. int countertwo = 0;
  18.  
  19. int resultone = 0;
  20. int resulttwo = 0;
  21.  
  22. string strOne = "";
  23. string strTwo = "";
  24.  
  25. //(Cardone!= "End of game")
  26.  
  27. while (true)
  28.  
  29. {
  30. strOne = Console.ReadLine();
  31. if (strOne == "End of game")
  32. {
  33. Console.WriteLine($"{firstname} has {counterone} points");
  34. Console.WriteLine($"{secondname} has {countertwo} points");
  35. break;
  36. }
  37. strTwo = Console.ReadLine();
  38. int cardOne = int.Parse(strOne);
  39. int cardTwo = int.Parse(strTwo);
  40.  
  41.  
  42. if (cardOne > cardTwo)
  43. {
  44. resultone = cardOne - cardTwo;
  45. counterone += resultone;
  46. }
  47. if (cardOne < cardTwo)
  48. {
  49. resulttwo = cardTwo - cardOne;
  50. countertwo += resulttwo;
  51. }
  52.  
  53. if (cardOne == cardTwo)
  54. {
  55. Console.WriteLine("Number wars!");
  56. cardOne = int.Parse(Console.ReadLine());
  57. cardTwo = int.Parse(Console.ReadLine());
  58. if (cardOne > cardTwo)
  59. {
  60. resultone = cardOne - cardTwo;
  61. Console.WriteLine($"{firstname} is winner with {counterone} points");
  62. }
  63. if (cardOne < cardTwo)
  64. {
  65. resulttwo = cardTwo - cardOne;
  66. Console.WriteLine($"{secondname} is winner with {resulttwo} points");
  67. }
  68. break;
  69. }
  70.  
  71. }
  72.  
  73.  
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement