Skip to content

Instantly share code, notes, and snippets.

@dzsquared
Created December 30, 2016 02:44
Show Gist options
  • Save dzsquared/bded31c0ce3b31e68a51f10facaab7fa to your computer and use it in GitHub Desktop.
Save dzsquared/bded31c0ce3b31e68a51f10facaab7fa to your computer and use it in GitHub Desktop.
arrays and loops created by dzsquared - https://repl.it/Ewyw/0
using System;
using System.Collections.Generic;
using System.IO;
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 lineCount;
lineCount = Convert.ToInt32(Console.ReadLine());
for(int i = 1; i <= lineCount; i++) {
string theword = Console.ReadLine();
char[] myCharArray = theword.ToCharArray();
string thehalfword = "";
string theotherhalfword = "";
for(int j = 0; j < theword.Length; j++){
if(j % 2 == 0) {
// Print each sequential character on the same line
thehalfword = thehalfword + myCharArray[j];
} else {
theotherhalfword = theotherhalfword + myCharArray[j];
}
}
Console.WriteLine(thehalfword + " " + theotherhalfword);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment