• + 0 comments

    Using stringbuilder in C#

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    class Solution {
        static void Main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
            int n = Convert.ToInt32(Console.ReadLine());
        
            for(int i = 0; i < n; i++) {
                string input = Console.ReadLine();
                var evenChars = new StringBuilder();
                var oddChars = new StringBuilder();
                
                for(int j = 0; j < input.Length; j++) {
                    if(j % 2 == 0)
                        evenChars.Append(input[j]);
                    else
                        oddChars.Append(input[j]);
                }
                
                Console.WriteLine($"{evenChars} {oddChars}");
            }
        }
    }