Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace GrabAndGo
- {
- class GrabAndGo
- {
- static void Main()
- {
- long[] numbers = Console.ReadLine()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(long.Parse)
- .ToArray();
- long fix = long.Parse(Console.ReadLine());
- long index = 0;
- long sum = 0;
- for (int i = 0; i < numbers.Length; i++)
- {
- if (numbers[i] == fix)
- {
- index = i;
- }
- }
- for (int i = 0; i < index; i++)
- {
- sum += numbers[i];
- }
- if (sum == 0)
- {
- Console.WriteLine("No occurrences were found!");
- }
- else
- {
- Console.WriteLine(sum);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment