Advertisement
sivancheva

GrabAndGo

Aug 19th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 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. using System.Numerics;
  7.  
  8. namespace _17_04_GrabAndGo
  9. {
  10. class GrabAndGo
  11. {
  12. static void Main(string[] args)
  13. {
  14. var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  15.  
  16. int number = int.Parse(Console.ReadLine());
  17.  
  18.  
  19. if (input.Contains(number))
  20. {
  21. int index = Array.LastIndexOf(input, number);
  22. BigInteger sum = input.Take(index).Sum();
  23.  
  24. Console.WriteLine(sum);
  25. }
  26. else
  27. {
  28. Console.WriteLine("No occurrences were found!");
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement