Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Numerics;
- namespace Grab_and_Go
- {
- class Program
- {
- static void Main(string[] args)
- {
- BigInteger[] numbers = Console.ReadLine()
- .Split(' ')
- .Select(BigInteger.Parse)
- .ToArray();
- BigInteger numberStop = BigInteger.Parse(Console.ReadLine());
- var count = 0;
- BigInteger sum = 0;
- for (int i = 0; i < numbers.Length; i++)
- {
- if (numbers[i] == numberStop)
- {
- count++;
- if(count == 2)
- {
- Console.WriteLine(sum);
- break;
- }
- }
- sum += numbers[i];
- }
- if(count == 0)
- {
- Console.WriteLine("No occurrences were found!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement