Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Practice
- {
- class Program
- {
- static void Main(string[] args)
- {
- var nums = Console.ReadLine().Split()
- .Select(int.Parse).ToList();
- var exepCount = 0;
- while (exepCount < 3)
- {
- var input = Console.ReadLine().Split();
- var command = input[0];
- try
- {
- if (command == "Replace")
- {
- var index = int.Parse(input[1]);
- nums[index] = int.Parse(input[2]);
- }
- else if (command == "Print")
- {
- var index = int.Parse(input[1]);
- var endIndex = int.Parse(input[2]);
- Console.WriteLine
- (string.Join(", ", nums.GetRange(index, endIndex)));
- }
- else
- {
- var index = int.Parse(input[1]);
- Console.WriteLine(nums[index]);
- }
- }
- catch
- {
- if (input.Length > 2)
- {
- var check = 0;
- if (int.TryParse(input[1], out check) &&
- int.TryParse(input[2], out check))
- {
- Console.WriteLine("The index does not exist!");
- }
- else
- Console.WriteLine("The variable is not in the correct format!");
- }
- else
- {
- var check = 0;
- if (int.TryParse(input[1], out check))
- {
- Console.WriteLine("The index does not exist!");
- }
- else
- Console.WriteLine("The variable is not in the correct format!");
- }
- exepCount++;
- }
- }
- Console.WriteLine(string.Join(", ", nums));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement