Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as C++ by registered user xujiayu ( 4 years ago )
#include <stdio.h>
#include <conio.h>

/*
GIAI PHUONG TRINH BAC 1 BANG HAM-THU TUC
ax + b = 0 
cach giai : bien luan theo he so di kem voi an co mu cao nhat 

TH1:
+ a = 0
    => pt co dang : b = 0 
	+ b = 0 => pt vo so nghiem 
	+ b != 0 => pt vo nghiem 
	th2:
a != 0 => tinh nghiem x = -b/a*/

void nhapdulieu (double &x)
{
	 printf ("\nHay nhap so : ");
	 scanf("%lf",&x);
}
void giaiphuongtrinhbac1 (double a , double b)
{
	 if (a == 0)
	 {  
		 if(b == 0)
		 {
		    printf("\nPt vo so nghiem");
		 }
		 else
		 {
			 printf("\nPT vo nghiem");
		 }
	 
	 }
	 else
	 {
		 double x = -b/a;
		 printf("\nPT co nghiem x = %lf",x);
	 }
}

int main()
{     
	double a , b;

	nhapdulieu(a);
	nhapdulieu(b);
	giaiphuongtrinhbac1(a,b);
	
	/*gia su o duoi nay ta co nhu cau lay nghiem x ra de xu dung ,ta them tham chieu x vao phan 
	giaiphuongtrinhbac1 o duoi tao them 1 bien x vay la co the lay duoc ket qua x tu do de xu dung tiep */
	getch();
	return 0;



}

 

Revise this Paste

Your Name: Code Language: