あにす #4696(2007/12/09 08:02 GMT) [ C# ] Rating0/0=0.00
テキストの2行目から文字でループを回し、次の文字が"-"の時に、1行目の文字を入れ替えてます。 ループが終わったら1行目を最終行に足して、入れ替えた1行目を復元して出力してます。
see: 貧脚レーサーのサボり日記
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//http://ja.doukaku.org/103/ 投稿用 using System; using System.Collections.Generic; class Program { static void Main(string[] args) { Amida(@"A B C D E | | |-| | |-| | |-| | |-| |-| |-| |-| | |-| | | |"); Console.ReadLine(); } static void Amida(string amidaText) { string[] amidaTemp = amidaText.Split(new char[]{'\n'}); List<char[]> amidaRows = new List<char[]>(); amidaRows.Add(amidaTemp[0].ToCharArray()); for(int i = 1; i < amidaTemp.Length; i++) { amidaRows.Add(amidaTemp[i].ToCharArray()); for(int j = 0; j < amidaTemp[i].Length; j = j + 2) { if(j > 0 && amidaTemp[i][j - 1] == '-') { char tmp; tmp = amidaRows[0][j]; amidaRows[0][j] = amidaRows[0][j - 2]; amidaRows[0][j - 2] = tmp; } } } amidaRows.Add(amidaRows[0]); amidaRows.RemoveAt(0); amidaRows.Insert(0, amidaTemp[0].ToCharArray()); foreach(char[] line in amidaRows) { Console.WriteLine(line); } } }
Rating0/0=0.00-0+
[ reply ]
あにす
#4696()
[
C#
]
Rating0/0=0.00
テキストの2行目から文字でループを回し、次の文字が"-"の時に、1行目の文字を入れ替えてます。 ループが終わったら1行目を最終行に足して、入れ替えた1行目を復元して出力してます。
see: 貧脚レーサーのサボり日記
Rating0/0=0.00-0+
[ reply ]