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

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

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

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Minh Nghia [T1907A]
Minh Nghia

2020-05-13 14:11:15



using System;
using System.Text;

namespace PTBac2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            Console.Write("Nhap vao a :");
            float a = float.Parse(Console.ReadLine());

            if (a == 0)
            {
                Console.WriteLine("a phai khac 0");
            }
            else
            {
                Console.WriteLine("Nhap vao b :");
                float b = float.Parse(Console.ReadLine());

                float x = -b / a;
                Console.WriteLine("{0}x + {1} = 0 \n=> {2}", a, b, x);
            }
            Console.ReadKey();
        }
    }
}
    



Thành Lâm [T1907A]
Thành Lâm

2020-05-13 13:42:40



using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Nhập A và B để tìm x (x là số chẵn ): ");
            Console.WriteLine("Nhập a:");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("A = " + a);
            Console.WriteLine("Nhập b:");
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine("B = " + b);

            Console.WriteLine("Phương Trình hiện có:" + a + "x + " + b + " = 0");
            int c = -b / a;
            Console.WriteLine("x = " + c);
            Console.ReadKey();

        }
    }
}



Đỗ tuấn anh [T1907A]
Đỗ tuấn anh

2020-05-13 11:58:31



using System;

namespace helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("nhap he so a:");
            int a = int.Parse(Console.ReadLine());
            Console.Write("Nhap he so b:");
            int b = int.Parse(Console.ReadLine());
            if (a == 0)
                if (b == 0)
                    Console.WriteLine("phuong trinh co 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();
        }
    }
}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-05-13 11:52:58



using System;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Nhập vào a: ");
            float a = float.Parse(Console.ReadLine());

            if (a == 0)
            {
                Console.WriteLine("a phải khác 0");
            }
            else
            {
                Console.WriteLine("Nhập vào b: ");
                float b = float.Parse(Console.ReadLine());

                float x = -b / a;
                Console.WriteLine("{0}x + {1} = 0 \n=> x = {2}", a, b, x);
            }
            Console.ReadKey();
        }
    }
}



nguyễn văn huy [T1907A]
nguyễn văn huy

2020-05-13 11:18:11



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

namespace PTbac1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            Console.WriteLine("Nhập vào a : ");
            float a = float.Parse(Console.ReadLine());

            if (a == 0)
            {
                Console.WriteLine("a phải khác 0");
            }
            else
            {
                Console.WriteLine("Nhập vào b : ");
                float b = float.Parse(Console.ReadLine());

                float x = -b / a;
                Console.WriteLine("{0}x + {1} = 0 \n  => x = {2}", a, b, x);
            }
            Console.ReadKey();
        }
    }
}



Lê Minh Bắc [T1907A]
Lê Minh Bắc

2020-05-13 09:31:46



using System;

namespace Test
{
	class Class1
	{
		static void Main(string[] args)
		{
			int a, b, x;
			Console.WriteLine("Nhap a: ");
			a = Convert.ToInt32(Console.ReadLine());
			Console.WriteLine("Nhap b: ");
			b = Convert.ToInt32(Console.ReadLine());
			if (a == 0)
			{
				if (b == 0)
				{
					Console.WriteLine("PT vo so nghiem");
				}
				else
				{
					Console.WriteLine("PT vo nghiem");
				}
			}
			else
			{
				x = -b / a;
				Console.WriteLine("PT co 1 nghem duy nhat x = " + x);
			}
			Console.ReadKey();
		}
	}
}



Trương Công Vinh [T1907A]
Trương Công Vinh

2020-05-13 09:31:32



using System;
using Microsoft.VisualBasic.CompilerServices;

namespace ptb1
{
    class Program
    {
        
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
                int a, b;
                Console.WriteLine("nhap a : ");
                a = int.Parse(Console.ReadLine());
            Console.WriteLine("nhap b : ");
                b = int.Parse(Console.ReadLine());
            ptb1(a, b);

            }
               
        static String showString(int a, int b)
        {
            return "pt : " + a + "x + " + +b +" = 0";
        }
        static void ptb1(int a, int b)
            {
            if(a == 0)
            {
                if (b == 0)
                {
                    Console.WriteLine(showString(a,b)+"co vo so nghiem");
                }
                else
                {
                    Console.WriteLine(showString(a,b)+"vo nghiem");
                }
            }
            else
            {
                float x = (-b) / a;
                Console.WriteLine("nghiem cua  " + showString(a, b) + " la x = " + x);
            }

            }
        
    }
}



Trần Mạnh Dũng [T1907A]
Trần Mạnh Dũng

2020-05-13 09:27:48



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

namespace PTbac1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            bool check = true;
            while (check)
            {
                Console.WriteLine("==============");
                Console.WriteLine("Enter a: ");
                float a = float.Parse(Console.ReadLine());
                if (a == 0)
                {
                    Console.WriteLine("A # 0");
                }
                else
                {
                    Console.WriteLine("Enter b: ");
                    float b = float.Parse(Console.ReadLine());

                    float x = -b / a;
                    Console.WriteLine("{0}x + {1} = 0 \n => x = {2}", a, b, x);
                   
                }
                Console.ReadKey();
            }

            
        }
    }
}



Nguyễn Văn Quang [T1907A]
Nguyễn Văn Quang

2020-05-13 09:19:16



using System;

namespace T1907A
{
 

    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            Console.WriteLine("Nhập vào a: ");
            float a = float.Parse(Console.ReadLine());

            if (a == 0)
            {
                Console.WriteLine("a phải khác 0");
            }
            else
            {
                Console.WriteLine("Nhập vào b: ");
                float b = float.Parse(Console.ReadLine());

                float x = -b / a;
                Console.WriteLine("{0}x + {1} = 0 \n=> x = {2}", a, b, x);
            }
            Console.ReadKey();
        }
    }
}



Phan Bạch Tùng Dương [T1907A]
Phan Bạch Tùng Dương

2020-05-13 09:18:37



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

namespace GiaiPTBac1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            Console.WriteLine("Nhập vào a : ");
            float a = float.Parse(Console.ReadLine());

            if (a == 0)
            {
                Console.WriteLine("a phải khác 0");
            }
            else
            {
                Console.WriteLine("Nhập vào b : ");
                float b = float.Parse(Console.ReadLine());

                float x = -b / a;
                Console.WriteLine("{0}x + {1} = 0 \n  => x = {2}", a, b, x);
            }
            Console.ReadKey();
        }
    }
}