解决方案 »

  1.   

    我这里就不用WinForm了  直接用控制台代码吧string[] textList   = {"1","2","3","4","5","6","7","8","9"};
    //int[]    countList  = { 0 , 0 , 1 , 0 , 2 , 1 , 0 , 0 , 0 };
    //int[]    jumpList   = { 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 };int[]    countList =  { 0 , 0 , 1 , 0 , 2 , 1 , 0 , 2 , 0 };
    int[]    jumpList   = { 0 , 0 , 0 , 0 , 0 , 1 , 0 , 2 , 0 };List<List<string>> logList = new List<List<string>>();
    for (int i = 0; i < textList.Length; i++)
    {
        List<string> tempList = new List<string>();
        logList.Add(tempList);
        for (int c = 0; c <= countList[i]; c++)
        {
            tempList.Add(textList[i]);
            Console.WriteLine(textList[i]);
            if (c == countList[i]) continue;
            for (int j = i - jumpList[i]; j < i; j++)
            {
                tempList.AddRange(logList[j]);
                foreach (string v in logList[j])
                {
                    Console.WriteLine(v);
                }
            }
        }
    }
      

  2.   


    其实我也觉得这个问题有点奇怪,有点像我天朝的奥(wu)数(liao)风格
      

  3.   

    <!DOCTYPE html>
    <html>
        <head>
            <title>结贴啦</title>
        </head>
        <body></body>
        <script type="text/javascript">
            var arr = [
                ['1', 0, 0],
                ['2', 0, 0],
                ['3', 1, 0],
                ['4', 0, 0],
                ['5', 2, 0],
                ['6', 1, 1],
                ['7', 0, 0],
                ['8', 2, 2],
                ['9', 0, 0]
            ], str = [];        (function fx(x, y) {
                for(;x < y; x++) {
                    str.push(arr[x][0]);
                    for(var i = 0; i < arr[x][1]; i++) {
                        fx(x - arr[x][2], x);
                        str.push(arr[x][0]);
                    }
                }
            })(0, arr.length);        document.body.innerHTML = str.join('<br/>');
    </script>
    </html>
      

  4.   

    现在的人啊,只会用现成的代码啦,给你C#版的
    static void Main(string[] args)
            {
                var arr = new object[9, 3]{
                     {"1", 0, 0},
                     {"2", 0, 0},
                     {"3", 1, 0},
                     {"4", 0, 0},
                     {"5", 2, 2},
                     {"6", 1, 1},
                     {"7", 0, 0},
                     {"8", 2, 2},
                     {"9", 0, 0}
                };            fx(arr, 0, 9);
            }
            static void fx(object[,] arr, int x, int y)
            {
                for (; x < y; x++)
                {
                    Console.WriteLine(arr[x,0]);
                    for (var i = 0; i < (int)arr[x, 1]; i++)
                    {
                        fx(arr, x - (int)arr[x, 2], x);
                        Console.WriteLine(arr[x, 0]);
                    }
                }
            }
      

  5.   

    给你来个复杂的版本
        class Program
        {
            static void Main(string[] args)
            {
                RuleExecuter exec = new RuleExecuter();            exec.AddRule("1", 0, 0);
                exec.AddRule("2", 0, 0);
                exec.AddRule("3", 1, 0);
                exec.AddRule("4", 0, 0);
                exec.AddRule("5", 2, 0);
                exec.AddRule("6", 1, 1);
                exec.AddRule("7", 0, 0);
                exec.AddRule("8", 2, 2);
                exec.AddRule("9", 0, 0);            exec.Execute(Console.Out);            Console.ReadKey();
            }
        }    class Rule
        {
            public Rule(string content, int max, int jump)
            {
                Content = content;
                MaxOutput = max;
                Jump = jump;
            }        /// <summary>
            /// 文本
            /// </summary>
            public string Content { get; set; }        /// <summary>
            /// 输出次数
            /// </summary>
            public int MaxOutput { get; set; }        /// <summary>
            /// 跳转
            /// </summary>
            public int Jump { get; set; }        int _count;        public void Execute(TextWriter output)
            {
                output.WriteLine(Content);
                _count++;
            }        public bool HasFinished
            {
                get { return _count > MaxOutput; }
            }        public void Reset()
            {
                _count = 0;
            }
        }    class RuleExecuter
        {        public RuleExecuter()
            {
                _rules = new List<Rule>();
            }        private List<Rule> _rules;        public List<Rule> Rules
            {
                get { return _rules; }
            }        public Rule AddRule(string content, int max, int jump)
            {
                Rule rule = new Rule(content, max, jump);
                _rules.Add(rule);
                return rule;
            }        public void Execute(TextWriter output)
            {
                Rule[] array = _rules.ToArray();
                int index = 0, length = array.Length;            while (index < length)
                {
                    Rule rule = array[index];                if (rule.HasFinished)
                        rule.Reset();                rule.Execute(output);                if (!rule.HasFinished)
                    {
                        index -= rule.Jump;
                    }
                    else
                        index++;
                }
            }
        }
      

  6.   


    public class mainclass
    {
            public void main()
    {
    var writeobjects=new List<WriteObject>(){new WriteObject("1",0,0)};
    WriteArry(writeobjects);
    }
            public void Write(StringBuilder sb, WriteObject writeObject)
            {
                for (int i = 0; i <= writeObject.Times; i++)
                {
                    sb.AppendLine(writeObject.Text);
                }
            }        public void WriteArry(List<WriteObject> objects)
            {
                var sb=new StringBuilder();
                for (int i = 0; i < objects.Count; i++)
                {
                    var writeObject = objects[i];
                    Write(sb, writeObject);
                    if (writeObject.JumpIndex > 0)
                    {
                        Write(sb, objects[i-writeObject.Times]);
                    }
                }
            }
        }    public class WriteObject
        {
            public string Text { get; set; }
            public int Times { get; set; }
            public int JumpIndex { get; set; }
            public WriteObject(string text,int times,int jumpindex)
    {
    Text=text;
    Times=times;
    JumpIndex=jumpindex;
    }
        }