Example #1
0
        /// <summary>
        /// 发送短信异步 群发
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string SendSMS_ASYN(List<string> mobile, string content)
        {            
            SMSModel m = new SMSModel
            {
                mobile = mobile.ListToString(),
                sendContents = content
            };

            ThreadPool.QueueUserWorkItem(new WaitCallback(SendInfo), m);
            return "ok";
        }
Example #2
0
        /// <summary>
        /// The nested loop strategy below is really fast
        /// </summary>
        public void Solve() {
            var t = new List<int>();

            for (int a = 1; a < 1000; a++) {
                for (int b = a + 1; b < 1000; b++) {
                    for (int c = b + 1; c < 1000; c++) {
                        if ((a + b + c == 1000) && (a.Sqr() + b.Sqr() == c.Sqr())) {
                            t.AddRange(new int[] { a, b, c });
                            break;
                        }
                    }
                }
            }

            Util.WL("The pythagorean triple whose sum equals 1000 is: {0}\nThe product of this triple is: {1}"
                .FormatWith(t.ListToString(), t.Product()));

            //LinqStrategy();
        }
Example #3
0
        public void Solve() {
            var nums = GetNums();
            var greatest = 0;
            List<int> glist = new List<int>();
            var i = 0;

            while (i + 5 <= nums.Count()) {
                var x = nums.Skip(i).Take(5).Aggregate((n, m) => n * m);
                
                if (greatest < x) {
                    greatest = x; 
                    glist = nums.Skip(i).Take(5).ToList();
                }

                i++;
            }

            Util.WL("The five consecutive digits {0} yield the greatest product {1}"
                    .FormatWith(glist.ListToString(), greatest));

            //LinqStrategy();
        }
Example #4
0
        /// <summary>
        /// 发送短信同步
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string SendSMS(List<string> mobile, string content)
        {
            SMSModel m = new SMSModel
            {
                mobile = mobile.ListToString(),
                sendContents = content
            };

            return SendInfo_t(m);
        }