Guest User

Petars Game

a guest
Jul 14th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. class PetarsGame
  5. {
  6. static void Main()
  7. {
  8. ulong startNum = ulong.Parse(Console.ReadLine());
  9. ulong endNum = ulong.Parse(Console.ReadLine());
  10. string strReplace = Console.ReadLine();
  11. ulong sum = 0;
  12.  
  13. for (ulong i = startNum; i < endNum; i++)
  14. {
  15. if (startNum % 5 == 0)
  16. {
  17. sum += startNum;
  18. }
  19. else
  20. {
  21. sum += startNum % 5;
  22. }
  23. startNum++;
  24. }
  25.  
  26. string sumStr = Convert.ToString(sum);
  27.  
  28. if (sum % 2 == 0)
  29. {
  30. string firstDigit = sumStr.Substring(0, 1);
  31. sumStr = sumStr.Replace(firstDigit, strReplace);
  32. }
  33. else
  34. {
  35. string lastDigit = sumStr.Substring(sumStr.Length - 1, 1);
  36. sumStr = sumStr.Replace(lastDigit, strReplace);
  37. }
  38. Console.WriteLine(sumStr);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment