zoukankan      html  css  js  c++  java
  • 补0

    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/>");
        }

  • 相关阅读:
    分享:TreeFrog 1.3 发布,基于 C++/QT 的 Web 框架
    Linux环境进程间通信(五): 共享内存(上)
    TUP第二期:架构师王鹏云演讲实录 _业界_科技时代_新浪网
    发布我的倒排索引 C/C++ ChinaUnix.net
    操作系统内存管理——分区、页式、段式管理
    内存管理内幕
    IT农民工如何来美国工作
    来自 王斌 (@iwangbin) 的推文
    ScheduledExecutorService执行周期性或定时任务
    PHP XML parse error: Extra content at the end of the document
  • 原文地址:https://www.cnblogs.com/zwei1121/p/1241502.html
Copyright © 2011-2022 走看看