Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<string> toBeInserted = new List<string>();
- List<string> inputs = Console.ReadLine().Split(" ").ToList(); //1 2 4 5 6 7
- List<string> outputs = new List<string>();
- while (true)
- {
- List<string> UserCommands = Console.ReadLine().Split(" ").ToList(); //contains 1
- if (UserCommands[0] == "add")
- {
- inputs.Insert(int.Parse(UserCommands[1]), UserCommands[2]);
- }
- else if(UserCommands[0] == "addMany")
- {
- toBeInserted.Clear();
- for (int a = 2; a < UserCommands.Count; a++)
- {
- toBeInserted.Add(UserCommands[a]);
- }
- inputs.InsertRange(int.Parse(UserCommands[1]), toBeInserted);
- }
- else if(UserCommands[0] == "contains")
- {
- string printContains = string.Empty;
- for (int b = 0; b < inputs.Count; b++)
- {
- if (inputs[b] == UserCommands[1])
- {
- printContains = b.ToString();
- }
- }
- if(printContains == string.Empty)
- {
- outputs.Add("-1");
- }
- else
- {
- outputs.Add(printContains);
- }
- }
- else if(UserCommands[0] == "print")
- {
- foreach(string smth2 in outputs)
- {
- Console.WriteLine(smth2);
- }
- foreach (string smth in inputs)
- {
- Console.Write(smth + " ");
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement