[ create a new paste ] login | about

Link: http://codepad.org/D0vXXxhA    [ raw code | output | fork ]

C, pasted on Apr 26:
/*
ax + by = c (1)
dx + ey = f (2)

Từ (1) => x = (c - by)/a (*) với a khác 0
Thế x vào (2)
=> d(c - by)/a + ey = f
<=> (dc - dby)/a + ey = f
<=> dc - dby + eya = fa
<=> (ea - db)y = fa - dc
<=> y = (fa - dc)/(ea - db) với mẫu khác 0
Thế vào (*)
=> x = (c - by)/a
*/
#include <stdio.h>
#include <conio.h>

int main()
{
	float a, b, c, d, e, f;

	printf("\nNhap he so a = ");
	scanf_s("%f", &a);

	printf("\nNhap he so b = ");
	scanf_s("%f", &b);

	printf("\nNhap he so c = ");
	scanf_s("%f", &c);

	printf("\nNhap he so d = ");
	scanf_s("%f", &d);

	printf("\nNhap he so e = ");
	scanf_s("%f", &e);

	printf("\nNhap he so f = ");
	scanf_s("%f", &f);

	double D, Dx, Dy, x ,y ;
	D = a * e - d * b;
	Dx = c * e - f * b;
	Dy = a * f - d * c;
	
	

	if (d) //Là kiểm tra giá trị chân lý của d. Nếu d == 0 thì trả về false, nếu d != 0 thì trả về true.
	{
		x = Dx / d;
		y = Dy / d;
		printf(" He phuong trinh co nghiem duy nhat (x,y)=(%.2f,%.2f)", x, y);
	}
	else if (Dx) printf(" he phuong trinh vo nghiem");
	else printf(" He phuong trinh co vo so nghiem");
	_getch();
	return 0;
}


Output:
1
Line 18: error: conio.h: No such file or directory


Create a new paste based on this one


Comments: