Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- namespace Final_Exam_April_04
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- var text = input;
- input = Console.ReadLine();
- while (input != "Done")
- {
- string[] arr = input.Split(" ").ToArray();
- string newCommnad = arr[0];
- if (newCommnad == "TakeOdd")
- {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < text.Length; i++)
- {
- if (!(i % 2 == 0))
- {
- sb.Append(text[i]);
- }
- }
- var result = sb.ToString();
- Console.WriteLine(result);
- }
- else if (newCommnad == "Cut")
- {
- int startIndex = int.Parse(arr[1]);
- int endIndex = int.Parse(arr[2]);
- if (startIndex >= 0 && endIndex < text.Length)
- {
- int length = endIndex - startIndex + 1;
- text = text.Remove(startIndex, length);
- Console.WriteLine(text);
- }
- }
- input = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement