Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace _17_04_GrabAndGo
- {
- class GrabAndGo
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int number = int.Parse(Console.ReadLine());
- if (input.Contains(number))
- {
- int index = Array.LastIndexOf(input, number);
- BigInteger sum = input.Take(index).Sum();
- Console.WriteLine(sum);
- }
- else
- {
- Console.WriteLine("No occurrences were found!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement