zwei1121

博客园 首页 新随笔 联系 订阅 管理

protected void btnTest_Click(object sender, EventArgs e)
    {
        int start = Convert.ToInt32(this.txtStart.Text);
        int end = Convert.ToInt32(this.txtEnd.Text);

        ArrayList al = new ArrayList();
        for (int j = start; j < end; j++)
        {
            al.Add(j.ToString());
        }

        string Num1Ext = string.Empty;
        string Num2Ext = string.Empty;
        string Num3Ext = string.Empty;

        double dkey = Math.Ceiling(al.Count / 9d);
        int key=Convert.ToInt32(dkey);

        List<string> NumList = new List<string>();
       
        for (int i = 1; i <=key; i++)
        {
            string result = string.Empty;
            int startPost=(i - 1) * 9;
            int count =0;
            string postfix = string.Empty;
           
            if (i == key)
            {
                count = al.Count;
                if (al.Count-i*9<0)
                {
                    postfix = "0000";
                }
            }
            else
            {
                count = 9 + startPost;
            }
           
            for (int t = startPost; t < count; t++)
            {
                result += al[t].ToString() + "|";
            }

            if (!string.IsNullOrEmpty(postfix))
            {
                result+=postfix;
            }

            NumList.Add(result);

            switch (i)
            {
                case 2: Num1Ext = result;
                    break;
                case 3: Num2Ext = result;
                    break;
                case 4: Num3Ext = result;
                    break;
                default:
                    break;
            }
        }


        for (int i = 1; i < NumList.Count; i++)
        {
            switch (i)
            {
                case 1: Num1Ext = NumList[i].ToString();
                    break;
                case 2: Num2Ext = NumList[i].ToString();
                    break;
                case 3: Num3Ext = NumList[i].ToString();
                    break;
                default:
                    break;
            }
        }


        foreach (string var in NumList)
        {
            Response.Write(var.ToString() + "</br>");
        }

        Response.Write(Num1Ext.TrimEnd('|') + "<br/>");
        Response.Write(Num2Ext.TrimEnd('|') + "<br/>");
        Response.Write(Num3Ext.TrimEnd('|') + "<br/>");
    }

posted on 2008-07-12 17:54  zwei  阅读(197)  评论(0编辑  收藏  举报