kiem tien, kiem tien online, kiem tien truc tuyen, kiem tien tren mang
Thứ Tư, 5 tháng 3, 2014


/*
Giải và biện luận phương trình bậc 2 (sử dụng ứng dụng Console)
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GiaiPT_bac2_console
{
    class Program
    {
        static void Main(string[] args)
        {
            float a, b, c;

            string xau;
            // Nhap a,b,c
            Console.WriteLine("\n Nhap he so: ");
            Console.Write("\n a= ");
            xau = Console.ReadLine();
            a = float.Parse(xau);
            Console.Write("\n b= ");
            xau = Console.ReadLine();
            b = float.Parse(xau);
            Console.Write("\n c= ");
            xau = Console.ReadLine();
            c = float.Parse(xau);

            // Giai va bien luan
            if (a == 0)
                if (b == 0)
                    if (c == 0)
                        Console.WriteLine("\n Phuong trinh vo so nghiem");
                    else
                        Console.WriteLine("\n Phuong trinh vo nghiem");
                else
                    Console.WriteLine("\n Phuong trinh co 1 nghiem x= {0}", c / b);
            else
            {
                
                float delta=b*b-4*a*c;
                if(delta<0)
                    Console.WriteLine("\n Phuong trinh vo nghiem");
                if(delta==0)
                    Console.WriteLine("\n Phuong trinh co nghiem kep x1=x2= {0}",-b/(2*a));
                if (delta > 0)
                {
                    float x1, x2;
                    x1 = (-b - (float)Math.Sqrt(delta)) / (2 * a);
                    x2 = (-b + (float)Math.Sqrt(delta)) / (2 * a);
                    Console.WriteLine("\n Phuong trinh co 2 nghiem x1= {0}; x2= {1}", x1, x2);
                }
            }
        }
    }
}
05 Mar 2014

0 nhận xét:

Đăng nhận xét

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

domain, domain name, premium domain name for sales

Bài đăng phổ biến