Advertisement
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 = Console.ReadLine();
- while (input != "End")
- {
- string[] tokens = input.Split();
- string command = tokens[0];
- if (command == "Complete")
- {
- int indexToFind = int.Parse(tokens[1]);
- if (indexToFind >= 0 && indexToFind < list.Count)
- {
- int completedTask = list.ElementAt(indexToFind);
- list[completedTask] = 0;
- }
- }
- else if (command == "Change")
- {
- int indexToLookFor = int.Parse(tokens[1]);
- int timeChange = int.Parse(tokens[2]);
- if (indexToLookFor >= 0 && indexToLookFor < list.Count)
- {
- //int timeToBeReplaced = list.ElementAt(indexToLookFor);
- list[indexToLookFor] = timeChange; // не трябва да е timeToBeReplaced
- }
- }
- else if (command == "Drop")
- {
- int indexToDrop = int.Parse(tokens[1]);
- if (indexToDrop >= 0 && indexToDrop < list.Count)
- {
- //int itemToDrop = list.ElementAt(indexToDrop);
- list[indexToDrop] = -1; // не трябва да е itemToDrop
- }
- }
- else if (command == "Count") // tokens[0] ти е само Count
- {
- int counter = 0;
- foreach (var completed in list.Where(x => x == 0))
- {
- counter++;
- }
- Console.WriteLine(counter);
- }
- else if (command == "Count Incomplete") //
- {
- int counter = 0;
- foreach (var incomplete in list.Where(x => x > 0))
- {
- counter++;
- }
- Console.WriteLine(counter);
- }
- else if (command == "Count Dropped")
- {
- int counter = 0;
- foreach (var dropped in list.Where(x => x < 0))
- {
- counter++;
- }
- Console.WriteLine(counter);
- }
- input = Console.ReadLine();
- }
- // foreach (var incompleteTask in list.Where(x => x > 0)) // не ти трябва след като ще ползваш string.Join
- //{
- Console.WriteLine(string.Join(" ", list.Where(x => x > 0)));
- //}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement