Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _01.StringManipulator
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- List<string> command = Console.ReadLine().Split().ToList();
- string word = command[0];
- while (word != "end")
- {
- if (word == "Translate")
- {
- string symbol = command[1];
- string replacement = command[2];
- input = input.Replace(symbol, replacement); //важно е да присвоим стойността
- Console.WriteLine(input);
- }
- else if (word == "Includes")
- {
- string word1 = command[1];
- bool result = input.Contains(word1);
- Console.WriteLine(result);
- }
- else if (word == "Start")
- {
- string word1 = command[1];
- bool result = input.StartsWith(word1);
- Console.WriteLine(result);
- }
- else if (word == "Lowercase")
- {
- input = input.ToLower();
- Console.WriteLine(input);
- }
- else if (word == "FindIndex")
- {
- string symbol = command[1];
- int lastindex = input.LastIndexOf(symbol);
- Console.WriteLine(lastindex);
- }
- else if (word == "Remove")
- {
- int start = int.Parse(command[1]);
- int count = int.Parse(command[2]);
- input = input.Remove(start, count);
- Console.WriteLine(input);
- }
- command = Console.ReadLine().Split().ToList();
- word = command[0];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment