人Ren都是达西,F#学习中,希望可以早日写出自己的F#版本,做个记号
推荐地址:http://www.cnblogs.com/allenlooplee/archive/2009/03/26/1421960.html
原文地址:http://blogs.msdn.com/jomo_fisher/archive/2007/11/17/tight-code-a-puzzle-in-f.aspx
public static void Main(string[] args)
{
//现在的我 = [['a';'b';'1'];['c';'d';'2'];['e';'f';'3']]
//想要变成 = [['a';'c';'e'];['b';'d';'f'];['1';'2';'3']]
string[,] list = { { "a", "b", "1" }, { "c", "d", "2" }, { "e", "f", "3" } };
StringBuilder sb = new StringBuilder();
sb.Append("{");
for (int i = 0; i < list.GetLength(0); i++)
{
sb.Append("{");
for (int j = 0; j < list.GetLength(1); j++)
{
sb.Append("\"" + list[j, i] + "\",");
}
sb.Remove(sb.ToString().Length - 1, 1);
sb.Append("},");
}
sb.Remove(sb.ToString().Length - 1, 1);
sb.Append("}");
Console.WriteLine(sb);
}
{
//现在的我 = [['a';'b';'1'];['c';'d';'2'];['e';'f';'3']]
//想要变成 = [['a';'c';'e'];['b';'d';'f'];['1';'2';'3']]
string[,] list = { { "a", "b", "1" }, { "c", "d", "2" }, { "e", "f", "3" } };
StringBuilder sb = new StringBuilder();
sb.Append("{");
for (int i = 0; i < list.GetLength(0); i++)
{
sb.Append("{");
for (int j = 0; j < list.GetLength(1); j++)
{
sb.Append("\"" + list[j, i] + "\",");
}
sb.Remove(sb.ToString().Length - 1, 1);
sb.Append("},");
}
sb.Remove(sb.ToString().Length - 1, 1);
sb.Append("}");
Console.WriteLine(sb);
}