源码:
class Program
    {
        public struct partstruct 
        {
            public int l;
            public int w;
            public int eTime;
            public int lTime;      
        }
        static void Main(string[] args)
        {
           for (int j = 1; j <= 7; j++)
           {
                partstruct[] B = new partstruct[500];
                for (int i = 0; i < n; i++)
                {
                    b1=0;
                    if ((j >= A[i].eTime && j <= A[i].lTime) 
                    {
                        B[b1] = A[i];
                    }
                }
                int m = B.Length;
                for (int i = 0; i < m; i++)
                {
                    if (B[i].w > B[i].l)
                    {
                        int temp = B[i].w;
                        B[i].w = B[i].l;
                        B[i].l = temp;
                    }
                }
           问题:首先将B中的lTime等于当前时间j的所有元素放在B的前面(升序),然后再将B中所有元素按长按宽降序排(lTime等于j的元素也按长按宽降序排)。例如:([2,4;1,5]、[3,6;2,4]、[8,3;1,3])排完之后为:([8,3;1,3]、[4,2;1,5]、[6,3;2,4])。
           }
        }
}

解决方案 »

  1.   

    什么意思?string str = "[2,4;1,5]、[3,6;2,4]、[8,3;1,3]";
                str = Regex.Replace(str, @"(\d)([,,])(\d)(?=;)", delegate(Match m)
                {
                    if (Convert.ToInt32(m.Groups[1].Value) < Convert.ToInt32(m.Groups[3].Value))
                        return m.Groups[3].Value + m.Groups[2].Value + m.Groups[1].Value;
                    else return m.Value;
                });
                var array = Regex.Matches(str, @"\[[^\]]*\]").Cast<Match>().Select(t => t.Value).OrderByDescending(t => Convert.ToInt32(Regex.Match(t, @"(?<=\[)\d(?=[,,]\d;)").Value)).ToArray();
                
      

  2.   

    @1楼:
    问题:首先将B中的lTime等于当前时间j的所有元素放在B的前面(升序),然后再将B中所有元素按长按宽降序排(lTime等于j的元素也按长按宽降序排)。例如:([2,4;1,5]、[3,6;2,4]、[8,3;1,3])排完之后为:([8,3;1,3]、[4,2;1,5]、[6,3;2,4])。
      [长,宽;eTime,lTime]
      

  3.   

    @3楼
       这个怪我,我没有写完整,其实在问题之后还有其它的方法,来处理这个顺序的。
       不会出现高shou 说的那种情况的。