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
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Minh Nghia [T1907A]](https://www.gravatar.com/avatar/ecca255d725eed36a872105205af1b8e.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/fb1b94f4caad069ee6e3f42ea2221b49.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/98f1e29922dc48dd5d41b8f6cbce24e0.jpg?s=80&d=mm&r=g)
Đỗ 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]](https://www.gravatar.com/avatar/c2ef7c316acb82467912bf5677b52a8b.jpg?s=80&d=mm&r=g)
Đườ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]](https://www.gravatar.com/avatar/b107d14d7d43c142b68c12c377262371.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/22abcac77d8ca5e01144e240abb48d22.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/223a7e3a46f4a747f81b921fe023fcc4.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/ee4661d1f9133c241d6c8287c7ea8ceb.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/e40ab58e34debd5a0dbf4bcfa90bded0.jpg?s=80&d=mm&r=g)
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]](https://www.gravatar.com/avatar/e74e3ec62fe3a191929e12eecbe01edf.jpg?s=80&d=mm&r=g)
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();
}
}
}