Created
November 12, 2013 17:11
-
-
Save yoshikazuendo/7434760 to your computer and use it in GitHub Desktop.
CodeIQ じぇじぇじぇなコードを書いてくんろ!
スパゲティ(spagetti)に紛れているナポリタン(neapolitan)を取り出して下さい。
のコードです。
https://codeiq.jp/ace/kansai_takako/q390
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var ret = ""; | |
string spagetti = "gtgtsgipgttptinggipsppaigsesgpetgstpatetisiesagaeaigttetepitiatsegssieeeeatepaaiagtpieataatppiitgiapsteitatiiatpetetetttgpetpaasipttssstpeeeggtiagtttegtiipestsasgpsepaasapttgattgiatppegitiatpasgatgepttggapesaeetaeissttggieietgspagesiipestipggstttpateptitiaetottissgggtttaipappgstsptttgtpispattgegstltiappseisapgistaiagteeiptptpisaieisagstapeteietgteiisgtiptstgtstasspeatspptitttatteastsgtptgtasggpniaaeteaisett"; | |
string neapolitan = "neapolitan"; | |
for (int i = 0; i < spagetti.Length; i++) { | |
char ch = spagetti[i]; | |
if (ch == neapolitan.First()) { | |
ret += "[" + ch + "]"; | |
neapolitan = neapolitan.Remove(0, 1); | |
if (neapolitan == "") { | |
ret += spagetti.Substring(i, spagetti.Length - i); | |
break; | |
} | |
} else { | |
ret += ch; | |
} | |
} | |
Console.WriteLine(ret.ToString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment