Yachkov

Untitled

Dec 5th, 2021 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Immutable;
  4. using System.ComponentModel.Design;
  5. using System.Data;
  6. using System.Diagnostics;
  7. using System.Globalization;
  8. using System.Linq;
  9. using System.Net.Http.Headers;
  10. using System.Runtime.InteropServices.ComTypes;
  11. using System.Security;
  12. using System.Text;
  13. using System.Transactions;
  14. using System.Xml.Linq;
  15. using System.Text.RegularExpressions;
  16. using System.Threading;
  17.  
  18. namespace Homework
  19. {
  20.     class Program
  21.     {
  22.         static void Main()
  23.         {
  24.             string line = Console.ReadLine();
  25.             string changedInput = line;
  26.             string[] command = Console.ReadLine().Split();
  27.             StringBuilder sb = new StringBuilder();
  28.             while (command[0] != "Done")
  29.             {
  30.                 if (command[0] == "Change")
  31.                 {
  32.                     string character = command[1];
  33.                     string replacement = command[2];
  34.                     line = line.Replace(character, replacement);
  35.                     Console.WriteLine(line);
  36.                 }
  37.                 else if (command[0] == "Includes")
  38.                 {
  39.                     string substring = command[1];
  40.                     if (line.Contains(substring))
  41.                     {
  42.                         Console.WriteLine("True");
  43.                     }
  44.                     else
  45.                     {
  46.                         Console.WriteLine("False");
  47.                     }
  48.                 }
  49.                 else if (command[0] == "End")
  50.                 {
  51.                     if (line.EndsWith(command[1]))
  52.                     {
  53.                         Console.WriteLine("True");
  54.                     }
  55.                     else
  56.                     {
  57.                         Console.WriteLine("False");
  58.                     }
  59.  
  60.                 }
  61.                 else if (command[0] == "Uppercase")
  62.                 {
  63.                     line.ToString();
  64.                     line = line.ToUpper();
  65.                     Console.WriteLine(line);
  66.                 }
  67.                 else if (command[0] == "FindIndex")
  68.                 {
  69.                     string character = command[1];
  70.                     int count = -1;
  71.                     foreach (var currChar in line)
  72.                     {
  73.                         count++;
  74.                         character.ToCharArray();
  75.                         if (currChar == character[0])
  76.                         {
  77.                             Console.WriteLine(count);
  78.                             break;
  79.                         }
  80.                     }
  81.                 }
  82.                 else if (command[0] == "Cut")
  83.                 {
  84.                     int startIndex = int.Parse(command[1]);
  85.                     int count = int.Parse(command[2]);
  86.                     changedInput = line.Substring(startIndex, count);
  87.                     Console.WriteLine(changedInput);
  88.                     break;
  89.                 }
  90.                 command = Console.ReadLine().Split();
  91.             }
  92.         }
  93.  
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment