示例#1
0
 public string[] PhuongTrinhBac2(double a, double b, double c)
 {
     string[] Nghiem = new string[2];
     if (a == 0)
     {
         cXuLy bt = new cXuLy();
         Nghiem[0] = Nghiem[1] = bt.PhuongTrinhBac1(b, c);
     }
     else
     {
         double delta = b * b - 4 * a * c;
         if (delta < 0)
         {
             Nghiem[0] = Nghiem[1] = "Phương trình vô nghiệm";
         }
         else if (delta > 0)
         {
             Nghiem[0] = ((-b + Math.Sqrt(delta)) / (2 * a)).ToString();
             Nghiem[1] = ((-b - Math.Sqrt(delta)) / (2 * a)).ToString();
         }
         else
         {
             Nghiem[0] = Nghiem[1] = (-b / (2 * a)).ToString();
         }
     }
     return(Nghiem);
 }
示例#2
0
        public string TaoMang(int n)
        {
            Random rd = new Random();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = rd.Next(100);
            }
            string s  = "";
            cXuLy  bt = new cXuLy();

            s = bt.InKetQua(s, arr);
            return(s);
        }
示例#3
0
        public string SapXepGiamDan(int[] arr, int n)
        {
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (arr[i] < arr[j])
                    {
                        int temp = arr[i];
                        arr[i] = arr[j];
                        arr[j] = temp;
                    }
                }
            }
            string s  = "";
            cXuLy  bt = new cXuLy();

            s = bt.InKetQua(s, arr);
            return(s);
        }