By GokiSoft.com| 15:16 14/05/2021|
C Sharp

Viết chương trình ax + b = 0 bằng C#, C Sharp BT1372

Viết chương trình ax + b = 0 bằng C#, C Sharp

Liên kết rút gọn:

https://gokisoft.com/1372

Bình luận

avatar
Đặng Trần Nhật Minh [T2008A]
2021-06-03 13:33:49



using System;

public class Program
{
	public static void Main()
	{
		float a, b, x;
		Console.WriteLine("Input a: ");
		a = float.Parse(Console.ReadLine());
		Console.WriteLine("Input b: ");
		b = float.Parse(Console.ReadLine());

		if (a == 0)
        {
			if (b == 0) Console.WriteLine("Infinite Solutions!");
			else Console.WriteLine("No Solutions!");
        }
        else
        {
			x = (-b) / a;
			Console.WriteLine("The Solution is x = {0}", x);
        }
	}
}


avatar
Do Trung Duc [T2008A]
2021-05-18 04:44:01



using System;

namespace Lesson1
{
    class Program
    {
        static void Main(string[] args)
        {
            float a, b, x;
            Console.WriteLine("Nhap a = ");
            a = Int32.Parse(Console.ReadLine());

            Console.WriteLine("Nhap b = ");
            b = Int32.Parse(Console.ReadLine());

            if (a==0) {
                if (b==0){
                    Console.WriteLine("phuong trinh vo so nghiem");
                }
                else
                {
                    Console.WriteLine("phuong trinh vo nghiem");
                }
            }
            else
            {
                x = -b / a;
                Console.WriteLine("phuong trinh co nghiem  x = {0}", x);
            }
            }
        }
    }



avatar
nguyễn Sử [T2008A]
2021-05-14 09:05:54



using System;

namespace ax___b___0
{
    class Program
    {
        static void Main(string[] args)
        {
            float z;

            Console.WriteLine("nhap x");
            float x = float.Parse(Console.ReadLine());

            Console.WriteLine("nhap y");
            float y = float.Parse(Console.ReadLine());

            if (x == 0)
            {
                if (y == 0)
                    Console.WriteLine("phuong trinh vo so nhiem");
                else
                {
                    Console.WriteLine("phuong trinh vo nhiem");
                }
            }
            else
            {
                z= -y / x;
                Console.WriteLine("nhiem:{0}", z);
            }

        }
    }
}


avatar
Nguyễn Tiến Đạt [T2008A]
2021-05-14 08:56:21



using System;

public class Program
{
	public static void Main()
	{
		float a, b;
		a = Convert.ToInt32(Console.ReadLine());
		b = Convert.ToInt32(Console.ReadLine());
		if (a == 0) Console.WriteLine("PTVN");
		else Console.WriteLine("x = {0}", -b / a);
	}
}


avatar
hainguyen [T2008A]
2021-05-14 08:45:40



using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Nhap x, y ");
            int x, y;
            float c;
            x = int.Parse(Console.ReadLine());
            y = int.Parse(Console.ReadLine());

            if (x == 0)
            {
                if (y == 0)
                    Console.WriteLine("Phuong trinh vsn");
                 else
                    Console.WriteLine("PTVN");
            }
            else
            {
                c = -y / x;
                Console.WriteLine("PT co 1 nghiem : " + c);
            }
        }
    }
}


avatar
vuong huu phu [T2008A]
2021-05-14 08:31:59



using System;

namespace baitap
{
    class Program
    {
        static void Main(string[] args)
        {
            float t;
            Console.WriteLine("nhap so a");
            float a = float.Parse(Console.ReadLine());
            Console.WriteLine("nhap so b");
            float b = float.Parse(Console.ReadLine());

            if (a == 0)
            {
                if (b == 0)
                {
                    Console.WriteLine("Phuong trinh vo so nghiem");
                }
                else
                {
                    Console.WriteLine("Phuong trinh vo nghiem");
                }
            }
            else {
                t = -b / a;
                Console.WriteLine("nghiem = " + t);
            }

        }
    }
}


avatar
NguyenHuuThanh [T1907A]
2020-05-18 04:57:41



using System;

namespace Bai_Tap_C__sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Nhap vao 2 so");
            int a, b;
            float c;
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            //ax + b = 0
            if ( a == 0 )
            {
                if (b == 0)
                    Console.WriteLine("Phương trình vsn);
                else
                Console.WriteLine("Phuong trinh vo nghiem");
            }    
            else 
            {
                c = (float)((-b) / a );
                Console.WriteLine("Phương trình có 1 no" + c);
            }    

        }
    }
}


avatar
Trần Anh Quân [T1907A]
2020-05-14 20:22:25



using System;

namespace ptb2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("nhap a:");
            int a = int.Parse(Console.ReadLine());
            Console.Write("Nhap b:");
            int b = int.Parse(Console.ReadLine());
            if (a == 0)
                if (b == 0)
                    Console.WriteLine("phuong trinh vo so nghiem");
              else
                    Console.WriteLine("Phuong trinh vo nghiem");
            else
            {
                int ketqua = -b / a;
                Console.WriteLine("phuong trinh co nghiem la x = {0}",
                ketqua.ToString());
            }
            Console.ReadKey();
        }
    }
}


avatar
Phạm Ngọc Minh [T1907A]
2020-05-14 08:20:08



using System;

namespace database
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("nhap a:");
            int a = int.Parse(Console.ReadLine());
            Console.Write("Nhap b:");
            int b = int.Parse(Console.ReadLine());
            if (a == 0)
                if (b == 0)
                    Console.WriteLine("phuong trinh vo so nghiem");
              else
                    Console.WriteLine("Phuong trinh vo nghiem");
            else
            {
                int ketqua = -b / a;
                Console.WriteLine("phuong trinh co nghiem la x = {0}",
                ketqua.ToString());
            }
            Console.ReadKey();
        }
    }
}


avatar
Đỗ Văn Huấn [T1907A]
2020-05-14 02:50:46



using System;

namespace Phuongtrinhbacnhat
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Moi ban nhap so a: ");
            float a = float.Parse(Console.ReadLine());
            Console.Write("Moi ban nhap so b: ");
            float b = float.Parse(Console.ReadLine());

            if (a==0)
            {
                if (b == 0)
                {
                    Console.WriteLine("Phuong trinh vo so nghiem.");
                    return;
                }
                Console.WriteLine("Phuong trinh vo nghiem.");
            }
            else
            {
                Console.WriteLine("Phuong trinh co 1 nghiem -b/a = " + (-b/a));
            }
        }
    }
}