Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4.  
  5. namespace Grab_and_Go
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. BigInteger[] numbers = Console.ReadLine()
  12. .Split(' ')
  13. .Select(BigInteger.Parse)
  14. .ToArray();
  15.  
  16. BigInteger numberStop = BigInteger.Parse(Console.ReadLine());
  17. var count = 0;
  18. BigInteger sum = 0;
  19. for (int i = 0; i < numbers.Length; i++)
  20. {
  21.  
  22. if (numbers[i] == numberStop)
  23. {
  24. count++;
  25. if(count == 2)
  26. {
  27. Console.WriteLine(sum);
  28. break;
  29. }
  30. }
  31. sum += numbers[i];
  32. }
  33. if(count == 0)
  34. {
  35. Console.WriteLine("No occurrences were found!");
  36. }
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement