Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 60 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top