silvana1303

password reset

Jul 25th, 2020 (edited)
605
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. using System.Runtime.InteropServices;
  6.  
  7. namespace _02._Boss_Rush
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.  
  15.             string[] command = Console.ReadLine().Split();
  16.  
  17.             while (command[0] != "Done")
  18.             {
  19.                 if (command[0] == "TakeOdd")
  20.                 {
  21.                     char[] chars = input.ToCharArray();
  22.                     string word = "";
  23.  
  24.                     for (int i = 0; i < chars.Length; i++)
  25.                     {
  26.                         if (i % 2 == 1)
  27.                         {
  28.                             word += chars[i];
  29.                         }
  30.                     }
  31.  
  32.                     input = word;
  33.                 }
  34.                 if (command[0] == "Cut")
  35.                 {
  36.                     int index = int.Parse(command[1]);
  37.                     int lenght = int.Parse(command[2]);
  38.  
  39.                     input = input.Remove(index, lenght);
  40.                 }
  41.                 if (command[0] == "Substitute")
  42.                 {
  43.                     //•   Substitute {substring} {substitute}
  44.                     if (input.Contains(command[1]))
  45.                     {
  46.                         input = input.Replace(command[1], command[2]);
  47.                     }
  48.                     else
  49.                     {
  50.                         Console.WriteLine("Nothing to replace!");
  51.                         command = Console.ReadLine().Split();
  52.                         continue;
  53.                     }
  54.                 }
  55.  
  56.                 Console.WriteLine(input);
  57.                 command = Console.ReadLine().Split();
  58.             }
  59.  
  60.             Console.WriteLine($"Your password is: {input}");
  61.         }
  62.     }
  63. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment