示例#1
0
        } = true;                                     // işlem değişkeni tanımlanıp başkangıç değeri true verildi.

        public void BigNumberFind()
        {
            while (Progression)                                                                                      // While döngüsü işlem true olduğu sürece dönmeye devam edecek.
            {
                try                                                                                                  // Hatalı girişe karşılık try catch blokları kullanıldı.
                {
                    Console.Write($"Lütfen { Counter }. Sayıyı Giriniz :");                                          // Ekrana sayı giriniz mesajı basıldı.
                    int getNum = int.Parse(Console.ReadLine());                                                      // Girilen numara int'a parse edildi.
                    if (getNum < 0 && Counter == 1)                                                                  // İlk girilen sayı 0 yada negatif kontrolü yapıldı.
                    {
                        Console.WriteLine($"{Counter } . sayıyı negatif girdiğiniz için en büyük sayı bulunamadı."); // uyarı mesajı basıldı.
                        break;
                    }
                    else
                    {
                        Counter++;                                                                                                                   // sayaç arttırıldı.
                    }
                    NumberList.Add(getNum);                                                                                                          // Listeye gelen numara eklendi.
                    if (getNum < 0)                                                                                                                  // numara küçükse Sayaç
                    {
                        NumberList.Sort();                                                                                                           //dizi sıralandı.
                        Console.WriteLine($"{Counter - 1 } Adet Girdiğiniz Sayılar içerisinde En Büyük Sayı : { NumberList[NumberList.Count - 1]}"); // - 1 adet girilen sayılardan listenin sonuncu elemanı en büyük olarak ekrana basıldı.
                        Progression = false;                                                                                                         // while döngüsünü kırması için  işlem false set edildi.
                    }
                }
                catch (Exception)                                     // herhangi bir hata durumunda tam sayı girmesi için exception mesajı basıldı.
                {
                    Console.WriteLine("Lütfen tam sayı giriniz...");; // hatalı durumda exp mesajı basılacak.
                }
            }
        }
示例#2
0
 // CREATING the private _build method here ---------------------------------------
 private void _build()
 {
     for (int i = 0; i < SetSize; i++)
     {
         NumberList.Add(i + 1);
     }
 }
        // CREATE the private _build method here -----------------------------------

        /*
         * add all the available numbers to _numberList
         */
        private void _build()
        {
            for (int i = 1; i <= SetSize; i++)
            {
                NumberList.Add(i);
            }
        }
示例#4
0
        // PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        // public PickElements method ----------------------------

        public void PickElements()
        {
            //checking if list is not empty
            if (ElementList.Count > 0)
            {
                //then clear method is called by both the lists
                ElementList.Clear();
                NumberList.Clear();
            }
            //m_build is called to rebuilt the NumberList
            m_build();

            m_random rn = new Random();

            //loop is created to generate random numbers
            for (int randomNumber = 1; randomNumber <= elementNumber; randomNumber++)
            {
                // it will select element from ElementList
                int number = rn.Next(1, ElementList.Count);
                //Remove the selected element from ElementList
                ElementList.Remove(number);
                //Add the element in NumberList
                NumberList.Add(number);
            }
        }
示例#5
0
 //  private _build method
 private void m_build()
 {
     //for loop to add integers in NumberList
     for (int num = 1; num <= SetSize; num++)
     {
         NumberList.Add(num);
     }
 }
示例#6
0
        // CREATE the private _build method here -----------------------------------

        private void _build()
        {
            // Add integer to NumberList from 1 to SetSize
            for (int i = 1; i <= SetSize; i++)
            {
                NumberList.Add(i);
            }
        }
        // CREATE the private _build method here -----------------------------------
        /// <summary>
        /// _build method will add random number to the number list, following set size condition
        /// </summary>
        private void _build()
        {
            int counter = 0;

            while (counter < SetSize)
            {
                NumberList.Add(random.Next(1, 99));
                counter++;
            }
        }
        private void _build()
        {
            int i = 1;

            while (i <= SetSize)
            {
                NumberList.Add(i);
                i++;
            }
        }
        static void NumbersListExample()
        {
            NumberList <int> numbers = new NumberList <int>();

            numbers.Add(4);
            numbers.Add(8);
            numbers.Add(15);
            numbers.Add(16);
            numbers.Add(23);
            numbers.Add(42);

            foreach (int num in numbers)
            {
                Console.WriteLine(num);
            }


            NumberList <int> myNumbers = new NumberList <int>()
            {
                100,
                200,
                300,
                400,
                500
            };
        }
示例#10
0
        static void CustomCollectionExample()
        {
            NumberList <int> list = new NumberList <int>();

            list.Add(4);
            list.Add(8);
            list.Add(15);
            list.Add(16);
            list.Add(23);
            list.Add(42);

            foreach (int number in list)
            {
                Console.WriteLine(number);
            }

            NumberList <int> numbers = new NumberList <int>
            {
                1, 2, 3, 4, 5, 6, 7
            };

            Console.WriteLine("========");

            foreach (int number in numbers)
            {
                Console.WriteLine(number);
            }
        }
        private void _addNumberByOne(string file)
        {
            var numbers  = LocalHelper.GetNumber(file);
            var comparer = new NumberItemComparer();

            foreach (var number in numbers)
            {
                var item = new NumberItem(number);
                //if (NumberList.ToList().Contains<NumberItem>(item, comparer)) continue;
                NumberList.Add(item);
            }
            Message = $"从{file}成功添加{numbers.Count}条号码!";
        }
        /// <summary>
        /// Add new numbers to list and increment repeat count by 2.
        /// </summary>
        /// <param name="numbers"></param>
        private static void AddNewNum(List <int> numbers)
        {
            NumbersAndRepeats numbersAndRepeats = new NumbersAndRepeats();

            numbersAndRepeats.Numbers = new List <int>();

            foreach (var item in numbers)
            {
                numbersAndRepeats.Numbers.Add(item);
            }
            numbersAndRepeats.Repeat = 2;

            NumberList.Add(numbersAndRepeats);
        }
示例#13
0
 public CheckingAccount(string name, double balance, int number)
 {
     if (number >= 500000)
     {
         if (NumberList.Contains(number))
         {
             Console.WriteLine("Account number already exists");
         }
         else
         {
             this.name    = name;
             this.balance = balance;
             this.number  = number;
             NumberList.Add(number);
         }
     }
 }
示例#14
0
            public int FindNumberOfLIS(int[] nums)
            {
                if (nums.Length == 0)
                {
                    return(0);
                }
                int index = 0;

                NumberList[] dp = new NumberList[nums.Length];
                dp[0] = new NumberList();
                dp[0].Add(nums[0], 1);
                for (int i = 1; i < nums.Length; i++)
                {
                    NumberList temp = new NumberList();
                    temp.Add(nums[i], 1);
                    if (nums[i] > dp[index].List.Last().Num)
                    {
                        temp.List.Last().Count = dp[index].GetCount(new NumberInfo {
                            Num = nums[i], Count = int.MaxValue
                        });
                        index++;
                        dp[index] = temp;
                    }
                    else
                    {
                        var idx = Array.BinarySearch(dp, 0, index + 1, temp, new NumberListComparer());
                        if (idx < 0)
                        {
                            idx = ~idx;
                        }
                        int count = 1;
                        if (idx > 0)
                        {
                            count = dp[idx - 1].GetCount(new NumberInfo {
                                Num = nums[i], Count = int.MaxValue
                            });
                        }
                        dp[idx].Add(nums[i], count);
                    }
                }
                return(dp[index].List.Last().Count);
            }
示例#15
0
 private void _getNumberByCity(string where, params MySqlParameter[] commandParameters)
 {
     Message = "查询开始。。。";
     NumberList.Clear();
     Task.Factory.StartNew(() =>
     {
         var watch = new Stopwatch();
         watch.Start();
         using (var conn = new MySqlConnection(DatabaseHelper.ConnectionString))
         {
             conn.Open();
             var command = new MySqlCommand($"SELECT n.number,m.number,m.city,m.type,m.city_code,m.postcode FROM `zd_number` n LEFT JOIN zd_mobile m ON n.mobile_id = m.id WHERE {where};", conn);
             foreach (var parm in commandParameters)
             {
                 command.Parameters.Add(parm);
             }
             var reader = command.ExecuteReader();
             while (reader.Read())
             {
                 if (reader.HasRows)
                 {
                     var item = new NumberInformation(
                         reader.GetString(0),
                         reader.GetString(1),
                         reader.GetString(2),
                         reader.GetString(3),
                         reader.GetString(4),
                         reader.GetString(5)
                         );
                     Application.Current.Dispatcher.Invoke(() =>
                     {
                         NumberList.Add(item);
                     });
                 }
             }
             reader.Close();
         }
         watch.Stop();
         _showMessage($"运行{watch.Elapsed},获得{NumberList.Count}条数据");
     });
 }
示例#16
0
 /// <summary>
 /// 获取全部结果进行正则匹配
 /// </summary>
 /// <param name="rule"></param>
 private void _getNumberByRules(string rule)
 {
     Message = "查询开始。。。";
     NumberList.Clear();
     Task.Factory.StartNew(() =>
     {
         var watch = new Stopwatch();
         watch.Start();
         using (var conn = new MySqlConnection(DatabaseHelper.ConnectionString))
         {
             conn.Open();
             var command            = new MySqlCommand("SELECT n.number,m.number,m.city,m.type,m.city_code,m.postcode FROM `zd_number` n LEFT JOIN zd_mobile m ON n.mobile_id = m.id;", conn);
             MySqlDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 if (reader.HasRows)
                 {
                     string number = reader.GetString(0);
                     if (Regex.IsMatch(number, rule))
                     {
                         var item = new NumberInformation(number,
                                                          reader.GetString(1),
                                                          reader.GetString(2),
                                                          reader.GetString(3),
                                                          reader.GetString(4),
                                                          reader.GetString(5)
                                                          );
                         Application.Current.Dispatcher.Invoke(() =>
                         {
                             NumberList.Add(item);
                         });
                     }
                 }
             }
             reader.Close();
         }
         watch.Stop();
         _showMessage($"运行{watch.Elapsed},获得{NumberList.Count}条数据");
     });
 }
 private void ExecuteRepeatCommand()
 {
     Task.Factory.StartNew(() =>
     {
         var watch = new Stopwatch();
         watch.Start();
         var enumerable = NumberList.ToList().Distinct <NumberItem>(new NumberItemComparer());
         Application.Current.Dispatcher.Invoke(() =>
         {
             NumberList.Clear();
         });
         foreach (var item in enumerable)
         {
             Application.Current.Dispatcher.Invoke(() =>
             {
                 NumberList.Add(item);
             });
         }
         watch.Stop();
         _showMessage($"去重完成!耗时{watch.Elapsed},剩余{NumberList.Count}条号码!");
     });
 }
示例#18
0
        static void ArrayAddExample()
        {
            NumberList <int> number = new NumberList <int>();

            number.Add(4);
            number.Add(8);
            number.Add(15);
            number.Add(16);
            number.Add(23);
            number.Add(42);


            Console.WriteLine(number.Count());

            Console.WriteLine("==========");
            foreach (int item in number)
            {
                Console.WriteLine(item);
            }
        }