Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - using System;
 - using System.Collections.Generic;
 - using System.Linq;
 - namespace _02._Problem
 - {
 - class Program
 - {
 - static void Main(string[] args)
 - {
 - var list = Console.ReadLine()
 - .Split(' ')
 - .Where(x => !string.IsNullOrWhiteSpace(x))
 - .Select(int.Parse)
 - .ToList();
 - string input;
 - while ((input = Console.ReadLine()) != "End")
 - {
 - string command = input.Split(" ")[0];
 - if (command == "Switch")
 - {
 - int index = int.Parse(input.Split(" ")[1]);
 - if (index >= 0 && index < list.Count)
 - {
 - int number = list[index];
 - list[index] = number - (number * 2);
 - }
 - }
 - else if (command == "Change")
 - {
 - int index = int.Parse(input.Split(" ")[1]);
 - int value = int.Parse(input.Split(" ")[2]);
 - if (index >= 0 && index < list.Count)
 - {
 - list[index] = value;
 - }
 - }
 - else if (command == "Sum")
 - {
 - string commandType = input.Split(" ")[1];
 - if (commandType == "Negative")
 - {
 - Console.WriteLine(list.Where(x => x < 0).Sum());
 - }
 - else if (commandType == "Positive")
 - {
 - Console.WriteLine(list.Where(x => x >= 0).Sum());
 - }
 - else if (commandType == "All")
 - {
 - Console.WriteLine(list.Sum());
 - }
 - }
 - }
 - Console.WriteLine(string.Join(" ", list.Where(x => x >= 0)));
 - }
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment