日期:2014-05-17  浏览次数:20738 次

求一算法....
数据如下
一、1 2 3 44
二、a b c d
三、e f

现在要写一个循环
1ae,1af,1be,1bf...............

问题是,行数是未知的,可能是三行也可以是十行。
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<List<string>> list = new List<List<string>>()
            {
                new List<string>() { "1", "2", "3", "44" },
                new List<string>() { "a", "b", "c", "d" },
                new List<string>() { "e", "f" }
            };
            var result = list.Aggregate((current, total) => total.Join(current, (string x) => 1, (string y) => 1, (string a, string b) => b + a).ToList());
            result.ForEach(x => { x.ToList().ForEach(y => Console.Write(y + " ")); Console.WriteLine(); });
        }
    }
}

------解决方案--------------------
 static void Main(string[] args)
        {
            List<string[]> list = new List<string[]>()
            {
                new string[]{"1","2","3","44"},
                new string[]{"a","b","c","d"},
                new string[]{"e","f"}

            };
            Fun(list, 0, "");
            Console.ReadLine();
        }
        static void Fun(List<string[]> list, int Row, string str)
        {
            if (Row == list.Count)
                Console.WriteLine(str);
            if (Row < list.Count)
&nbs