Untitled

Anonymous
Plain Text
09/02/2025 6:19 AM
753 B
12
Indexable
Never
using System;
using System.Text;

class Program
{
    static void Main()
    {
        Console.WriteLine("Enter the encoded string (e.g., 3A2B):");
        string input = Console.ReadLine();  // Read input from user

        StringBuilder output = new StringBuilder();
        int count = 0;

        foreach (char c in input)
        {
            if (char.IsDigit(c))
            {
                count = count * 10 + (c - '0'); // Allows for multi-digit numbers
            }
            else
            {
                output.Append(new string(c, count));  // Repeat character count times
                count = 0;
            }
        }

        Console.WriteLine("Decoded string: " + output.ToString());
    }
}
Editor is loading...
Leave a Comment