03. School Library Някой може ли да помогне
От 2 часа се блъскам с тази задача, при първата команда ми е грешката, но незнам как да го направя
Условие: https://judge.softuni.bg/Contests/Practice/Index/1958#2
Моето решение: https://pastebin.com/13PGPWiJ
using System;
using System.Collections.Generic;
using System.Linq;
namespace _03._School_Library
{
class Program
{
static void Main(string[] args)
{
List<string> booksLibrary = Console.ReadLine().Split('&').ToList();
List<string> newLibrary = new List<string>();
string input = Console.ReadLine();
while (input != "Done")
{
string[] spllited = input.Split(" | ");
if (spllited[0] == "Add Book")
{
string bookName = spllited[1];
if (!booksLibrary.Contains(bookName))
{
/// booksLibrary.Add(bookName);//mike pityr anna // mike = temp
string temp = booksLibrary[0];
booksLibrary[0] = bookName;
booksLibrary.Add(temp);
}
}
if (spllited[0] == "Take Book")
{
string bookName = spllited[1];
if (booksLibrary.Contains(bookName))
{
booksLibrary.Remove(bookName);
}
}
if (spllited[0] == "Swap Books")
{
string bookName = spllited[1];
string secondBokk = spllited[2];
if (booksLibrary.Contains(bookName) && booksLibrary.Contains(secondBokk))
{
int indexfirst = booksLibrary.IndexOf(bookName);
int indexSecond = booksLibrary.IndexOf(secondBokk);
string temp1 = booksLibrary[indexfirst];
string temp2 = booksLibrary[indexSecond];
booksLibrary[indexfirst] = temp2;
booksLibrary[indexSecond] = temp1;
}
}
if (spllited[0] == "Insert Book")
{
string bookName = spllited[1];
if (!booksLibrary.Contains(bookName))
{
booksLibrary.Add(bookName);
}
}
if (spllited[0] == "Check Book")
{
int index = int.Parse(spllited[1]);
if (index >= 0 && index <= booksLibrary.Count)
{
Console.WriteLine($"{booksLibrary[index]}");
}
}
input = Console.ReadLine();
}
Console.WriteLine(string.Join(", ",booksLibrary));
}
}
}
Whenever I need to watch any movie. I visit this site because here they provide us a lot of movie links. I downloaded it from here and watch it with my friends. Also you can visit https://interactivecasinos.org/casino-games/ to spend your free time with great casino games. Thanks for this incredible service. And now the next movie I am waiting for is a black widow.